Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GitHub と連携する CI を作る

Shunsuke Maeda
February 21, 2019

GitHub と連携する CI を作る

CI/CD TestNight #3 で発表したスライドです

Shunsuke Maeda

February 21, 2019
Tweet

More Decks by Shunsuke Maeda

Other Decks in Technology

Transcript

  1. طଘͷCIͷਏ͍ͱ͜Ζ • ઃఆϑΝΠϧ • CircleCI / TravisCI / Jenkins.. •

    *.yml / Jenkinsfile (= Groovy based DSL) • ϩʔΧϧͰͷ࠶ݱ౓ͷ௿͞ 05443d6 Fix ci setting ce8332d Fix ci setting 8c155fa Fix ci setting e6c24e0 Fix ci setting
  2. CIͷߏ੒(ࠓճ • ࣮ߦλΠϛϯά • GitHub ͷ Webhook • ࣮ߦ؀ڥ •

    Docker x λεΫϥϯφʔ • ࣮ߦ݁Ռ • GitHub ͷ Commit Status / ϩάUI
  3. GitHub ͷ Webhook • Event ͱ Action ͷ૊Έ߹ΘͤͰλΠϛϯά੍ޚ • Event

    • Webhookͷछྨ (Header: X-GitHub-Event) ྫ. push, issue_comment, pull_request • Action • Eventຖͷࡉ͔͍छྨ (JSON payload) ྫ. created, opened, synchronize
  4. Pull Request ͷίϝϯτ • issue_comment ͰऔಘՄೳ • Payload ʹ͸ pull_request

    ͷ৘ใ͕ͳ͍ (※ head branch/commit ͳͲ) => GitHub API Ͱऔಘ
  5. Dockerfile FROM golang:1.11.5-alpine RUN apk --update add --no-cache alpine-sdk COPY

    . . ENTRYPOINT ["make"] # λεΫϥϯφʔͷίϚϯυ ྫ. ./gradlew, mvn CMD ["test"] # σϑΥϧτͷλεΫ • docker build ͱ docker run Λ࣮ߦ • issue_comment ͷ৔߹͸ CMD ΛࢦఆՄೳ
  6. ϗετͷϦιʔε͸༗ݶ • ฒྻ਺ͱλΠϜΞ΢τ • Golang ͷ goroutine ͱ context ͕૬ੑ͕Α͍

    (࣮૷͕ؾʹͳΔํ͸) https://github.com/duck8823/duci/blob/master/ application/service/executor/executor.go
  7. GitHub Actions ͷ࣮ߦλΠϛϯά (Event • Event ͷछྨ͸ Webhook ͱجຊతʹ͸ಉ͡ •

    GitHub Actions https://developer.github.com/actions/creating- workflows/workflow-configuration-options/#events- supported-in-workflow-files • Webhooks https://developer.github.com/webhooks/#events
  8. GitHub Actions ͷ࣮ߦλΠϛϯά (Action • Webhook ͷ Payload ͱಉ౳ͷ JSON

    ͕഑ஔ͞ΕΔ ؀ڥม਺ GITHUB_EVENT_PATH • ެࣜͷ Filter • action Ͱ filter actions/bin
  9. ·ͱΊ • CI͸࡞ΕΔ • ࣮ߦλΠϛϯά / ࣮ߦ؀ڥ / ࣮ߦ݁Ռ •

    GitHub Actions ΋͍͍ͧ • CIΛ࡞ͬͨ஌ࣝ͸࢖͑Δ