Slide 1

Slide 1 text

GitHub Actions Deep Dive using PHP খࢁ݈Ұ࿠ / GMO PEPABO inc. 2022.4.10 PHPerKaigi 2022 1

Slide 2

Slide 2 text

ࣗݾ঺հ ٕज़෦ɹٕज़ج൫νʔϜ 2018೥ த్ೖࣾ খࢁ ݈Ұ࿠ Ken’ichiro Oyama গ࣮͠༻తͰখ͞ͳOSSΛॻ͘ͷ͕झຯɻ ● GitHub : k1LoW ● Twitter : @k1LoW 2

Slide 3

Slide 3 text

ΞδΣϯμ 1. GitHub Actions 2. GitHub ActionsͷΞʔΩςΫνϟ 3. ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions 4. Action 5. ͓ΘΓʹ 3

Slide 4

Slide 4 text

octocov 4

Slide 5

Slide 5 text

• https://github.com/k1LoW/octocov • ίʔυϝτϦΫεπʔϧ…ίʔυΧόϨοδɺCode to Test Ratioɺςετ࣮ߦ࣌ؒ • ଟ਺ͷϓϩάϥϛϯάݴޠͱɺओཁͳΧόϨοδϨϙʔτϑΥʔϚοτʹରԠ • GitHub Actionsͷactionͱͯ͠ίʔυϝτϦΫεΛूܭɺP/RίϝϯτɺϨϙʔτ • CLIπʔϧͱͯ͠ίʔυΧόϨοδΛूܭɻදࣔ • ΧόϨοδόοδੜ੒ octocov 5 5 octocov

Slide 6

Slide 6 text

octocov • octocov͸ίʔυϝτϦΫεΛࢦఆͷσʔλετΞʹอ࣋͢Δ͜ͱ͕Ͱ͖Δ • GitHub ArtifactsɺϩʔΧϧɺGitHubϦϙδτϦɺS3ɺGCSɺBigQuery • σʔλετΞͷ৘ใΛ࢖ͬͯϝτϦΫεͷࠩ෼ΛPRʹίϝϯτ • ผ్octocovΛ “CentralϞʔυ” ͱͯ͠ಈ͔͢͜ͱͰσʔλετΞʹ͋Δ֤Ϧϙδτ Ϧ͔Βૹ৴͞ΕͨίʔυϝτϦΫεΛऔಘ͠ɺҰཡදࣔ΍Ұׅͨ͠όοδੜ੒ͳͲ ͕Մೳ ίʔυϝτϦΫεσʔλͷૹ৴ɾऔಘɾ׆༻ 6

Slide 7

Slide 7 text

GitHub Actions 7

Slide 8

Slide 8 text

GitHub Actions GitHub Actions makes it easy to automate all your software work fl ows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want. https://github.com/features/actions GitHub ActionsΛ࢖༻͢ΔͱɺϫʔϧυΫϥεͷCI/CD؀ڥͰ͢΂ͯͷι ϑτ΢ΣΞϫʔΫϑϩʔΛ؆୯ʹࣗಈԽͰ͖·͢ɻ GitHub͔Β௚઀ίʔ υΛϏϧυɺςετɺσϓϩΠͰ͖ɺίʔυϨϏϡʔɺϒϥϯν؅ཧɺ IssueͷτϦΞʔδΛ๬Μͩ௨Γʹػೳͤ͞·͢ɻ 8

Slide 9

Slide 9 text

9 Cons Pros • GitHubϓϥοτϑΥʔϜͱ౷߹͞ Ε͍ͯΔͨΊɺGitHubҎ֎Ͱ͸ ࢖͍ͮΒ͍ • GitHubϦϙδτϦͱ౷߹͞Ε͍ͯ ΔͨΊ͙͢ʹར༻ՄೳɻϦϙδτ ϦͷίʔυͷCI/CDʹ࠷ద • GitHub ActionsͷϓϥάΠϯͱ͍ ͑ΔAction౳΋GitHubϦϙδτϦ ʹ͋ΔίʔυΛར༻͢ΔͨΊ͙͢ ʹར༻͕ՄೳʢʮϓϥάΠϯͷΠ ϯετʔϧʯͱ͍͏Α͏ͳεςο ϓ͕ෆཁʣ GitHub ActionsͷPros/Cons GitHub Actions

Slide 10

Slide 10 text

GitHub ActionsΛཧղ͢ΔͨΊͷྑ͍ϦϑΝϨϯε 10 GitHub Actions • ެࣜυΩϡϝϯτ • https://docs.github.com/ja/actions • ඇৗʹΘ͔Γ΍͍͢ͷͰΦεεϝ • ࣌ʑӳޠΑΓ΋৘ใྔ͕গͳ͍৔߹͕͋Δͷͱɺϖʔδ಺ϦϯΫ ͕ޮ͔ͳ͍ͷͰɺՄೳͳΒ https://docs.github.com/en/actions ΋֬ ೝ͍ͯͩ͘͠͞ʢϖʔδ্෦ͷϓϧμ΢ϯͰมߋՄೳͰ͢ʣ

Slide 11

Slide 11 text

11 GitHub Actionsͷ ΞʔΩςΫνϟ

Slide 12

Slide 12 text

• ϫʔΫϑϩʔ ( Workflow ) … A workflow is a configurable automated process that will run one or more jobs. • δϣϒ ( Job ) … A job is a set of steps in a workflow that execute on the same runner. • εςοϓ ( Step ) … Jobͷߏ੒ཁૉɻ೚ҙͷॲཧΛ࣮ߦ͢Δ୯Ґɻ 12 GitHub ActionsͷΞʔΩςΫνϟ ίϯϙʔωϯτ : Workflow / Job / Step ※ https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions ΑΓൈਮ

Slide 13

Slide 13 text

• Πϕϯτ ( Event ) … An event is a specific activity in a repository that triggers a workflow run. • ΞΫγϣϯ ( Action ) … An action is a custom application for the GitHub Actions platform that performs a complex but frequently repeated task. • ϥϯφʔ ( Runner ) … A runner is a server that runs your workflows when they're triggered. Each runner can run a single job at a time. 13 GitHub ActionsͷΞʔΩςΫνϟ ίϯϙʔωϯτ : Event / Action / Runner ※ https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions ΑΓൈਮ

Slide 14

Slide 14 text

• GitHub Actions͸EventΛτϦΨʔʹWorkflowΛىಈ͢Δɻ • Workflow͸1ͭ΋͘͠͸ෳ਺ͷJobΛ࣮ߦ͢Δɻ • Job͸1ͭ΋͘͠͸ෳ਺ͷStepͰߏ੒͞Ε͍ͯΔɻ • Step͸೚ҙͷॲཧΛ࣮ߦ͢Δ୯Ґɻ • Jobຖʹ1ͭͷRunnerͷ্Ͱ࣮ߦ͞ΕΔɻ • WorkflowͷதͰΑ࣮͘ࢪ͞ΕΔॲཧ͸Actionͱ͍͏1ͭͷॲཧͷ·ͱ·Γͱͯ͠੾Γग़͠ ࠶ར༻Ͱ͖ΔΑ͏ͳ࢓૊Έ͕͋ΔɻAction͸StepͰݺͼग़͢͜ͱͰ࢖༻͢Δɻطʹଟ͘ͷ Action͕GitHubϚʔέοτϓϨΠεͰެ։͞Ε͓ͯΓɺ·ͨ৽͘͠࡞੒͢Δ͜ͱ΋Մೳɻ 14 GitHub ActionsͷΞʔΩςΫνϟ GitHub ActionsͷΞʔΩςΫνϟ

Slide 15

Slide 15 text

15 GitHub ActionsͷΞʔΩςΫνϟ GitHub ActionsͷΞʔΩςΫνϟ

Slide 16

Slide 16 text

• 1YAML = 1Workflow • ԿͷEventΛτϦΨʔʹ͢Δ͔͸ on: ηΫγϣϯͱରԠ • WorkflowʹͿΒԼ͕ΔJob͸ jobs: ηΫγϣϯͱରԠ • JobʹͿΒԼ͕ΔStep͸ jobs..steps: ηΫγϣϯͱରԠ • ԿͷRunnerͷ্ͰJobΛಈ͔͔͢͸ jobs..runs-on: ηΫγϣϯͱରԠ • Action͸ uses: Ͱݺͼग़ͤ·͢ɻjobs..steps[*].uses: ηΫγϣϯͱରԠ • jobs..uses: Ͱ͸ Reusable Workflow ΋ݺͼग़͠Մೳ 16 GitHub ActionsͷΞʔΩςΫνϟ ֤ίϯϙʔωϯτͱ .github/workflows ʹஔ͘YAMLϑΝΠϧͷؔ܎

Slide 17

Slide 17 text

17 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷ GitHub Actions

Slide 18

Slide 18 text

Re: GitHub Actions GitHub Actions makes it easy to automate all your software work fl ows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want. https://github.com/features/actions GitHub ActionsΛ࢖༻͢ΔͱɺϫʔϧυΫϥεͷCI/CD؀ڥͰ͢΂ͯͷι ϑτ΢ΣΞϫʔΫϑϩʔΛ؆୯ʹࣗಈԽͰ͖·͢ɻ GitHub͔Β௚઀ίʔ υΛϏϧυɺςετɺσϓϩΠͰ͖ɺίʔυϨϏϡʔɺϒϥϯν؅ཧɺ IssueͷτϦΞʔδΛر๬Ͳ͓Γʹػೳͤ͞·͢ɻ 18

Slide 19

Slide 19 text

• GitHub ActionsΛʮCI/CD؀ڥʯͱͯ͠ଊ͑ͨ݁ՌʮΞϓϦέʔγϣϯͷςετͱσ ϓϩΠΛࣗಈԽ͢Δ؀ڥʯͩͱࢥΘΕ͕ͪ • ্هͷΑ͏ͳڱٛͷCI/CD͚ͩͰ͸ͳ͍ • ʮΞϓϦέʔγϣϯͷςετͱσϓϩΠʯ΋ؚΉ޿ٛͷCI/CD΍ϫʔΫϑϩʔࣗಈԽ Λ࣮ݱ͢Δػೳͱͯ͠ΈΔ 19 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions GitHub Actions͸ϫʔΫϑϩʔΛࣗಈԽͰ͖Δ

Slide 20

Slide 20 text

• δϣϒʢ= Jobʣͷґଘؔ܎ΛDAGʢ༗޲ඇ८ճάϥϑʣͰදݱͰ͖Δ • λεΫʢ= Step΍Job΍Workflowʣͷ੒൱͕֬ೝͰ͖Δ • ϩά͕Ұఆظؒอଘ͞Ε֬ೝͰ͖Δ 20 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions ຊൃදʹ͓͚ΔϫʔΫϑϩʔΤϯδϯͱ͸ ※ https://ja.wikipedia.org/wiki/༗ޮඇ८ճάϥϑ ΑΓ

Slide 21

Slide 21 text

21 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions • on: • needs: • jobs..needs: • if: • jobs..if: • jobs..steps[*].if: • uses: • jobs..steps[*].uses: • jobs..uses: DAGΛ࣮ݱ͢ΔͨΊͷϫʔΫϑϩʔߏจ

Slide 22

Slide 22 text

on: 22 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions • DAGʹ͓͚Δ࢝఺ʢͱͳΔ௖఺ʣʹͳΔߏจ • ίʔυͷPush΍Pull RequestҎ֎ʹ΋Issue΍Projectɺ DiscussionͳͲGitHubϓϥοτϑΥʔϜͷϦϙδτϦʹؔ܎͢Δ ཁૉͷ͞·͟·ͳΠϕϯτΛड͚औΕΔ • ఆظ࣮ߦ͕Ͱ͖Δ on.schedule: ͱϫʔΫϑϩʔΛ௚઀࣮ߦͰ͖ Δ repository_dispatch: ΍ workflow_dispatch: ͸རศੑ͕ߴ͍ • GitHubϓϥοτϑΥʔϜؔ܎ͳ͘ϫʔΫϑϩʔΛ࣮ߦͰ͖Δ

Slide 23

Slide 23 text

23 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions • jobs..needs: • ͦͷJobΛ࣮ߦ͢ΔͨΊʹඞཁͳJobΛྻڍͰ͖Δ • = JobΛ௚ྻʹܨ͛Δ͜ͱ͕Ͱ͖Δߏจ • ௨ৗ͸Runnerͷ਺͕ڐ͢ݶΓฒྻ࣮ߦ • = DAGʹ͓͚ΔϑΝϯΠϯɺϑΝϯΞ΢τΛ࣮ݱͰ͖Δߏจ needs:

Slide 24

Slide 24 text

24 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions • jobs..if: • jobs..steps[*].if: • ͦͷJob΍StepΛ࣮ߦ͢Δ͔Ͳ͏͔ͷ৚݅Λॻ͘͜ͱ͕Ͱ͖ Δ • ޙड़͢ΔContextͷ஋ΛExpressionsΛ࢖ͬͯ৚݅ࣜΛॻ ͘ • ৚݅෼ذΛ࡞੒Մೳͳߏจ if:

Slide 25

Slide 25 text

uses: 25 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions • jobs..steps[*].uses: • jobs..uses: • Action΍Reusable workflowΛݺͼग़͢ • = ผͷϦϙδτϦʹ·ͰDAGͷൣғΛ޿͛Δߏจ

Slide 26

Slide 26 text

• Expressions • PHPer͸ςϯϓϨʔτΤϯδϯ಺ͰόΠϯυͨ͠஋ΛࢀরͰ͖ͨΓɺҰ෦ؔ਺ ͕࢖͑ͨΓ͢ΔΞϨΛΠϝʔδ͍ͯͩ͘͠͞ • Context΍؀ڥม਺ΛݺͿͨΊʹ࢖༻ • if: ηΫγϣϯͰ͸৚݅ࣜΛॻͨ͘Ίʹ࢖͏ • Context • ࠓ࣮ߦ͍ͯ͠ΔWorkflowपลͷίϯςΩετ৘ใΛऔಘͰ͖Δ 26 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions DAGͷ੍ޚΛ͢ΔͨΊͷExpressions, Context

Slide 27

Slide 27 text

• if: ${{ github.event_name == ‘pull_request’ }} • Event͕pull_requestͩͬͨ৔߹ʹtrueɻҎ߱ͷλεΫΛ࣮ߦ • run: echo '${{ toJSON(github) }}’ • “github” ίϯςΩετΛJSONܗࣜͰඪ४ग़ྗʹग़ྗ • if: ${{ always() && contains(needs.*.result, ‘success') }} • ௚લͷJobͷগͳ͘ͱ΋1͕ͭ੒ޭ͍ͯ͠Δ৔߹ʹtrueɻҎ߱ͷJobΛ࣮ߦ 27 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions Example: Expressions, Context

Slide 28

Slide 28 text

28 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions Example DAG: fan-in fan-out

Slide 29

Slide 29 text

29 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions Example DAG: if-else

Slide 30

Slide 30 text

• Workflow commands • ඪ४ग़ྗ΁ग़ྗ͢Δ࣌ʹҰఆͷϑΥʔϚοτͰग़ྗ͢Δͱ஋Λอ࣋͢Δ͜ͱ͕Մೳ • run: echo '::set-output name=SELECTED_COLOR::green’ • SELECTED_COLORͱ͍͏໊લͰ green ͱ͍͏จࣈྻ͕อ࣋͞ΕΔ • ${{ steps..outputs.SELECTED_COLOR }} ͰऔಘՄೳ • Artifacts • δϣϒؒͰσʔλΛڞ༗͢Δ͜ͱ͕Մೳ • جຊతʹ actions/upload-artifactɺactions/download-artifactΛ࢖༻͢Δ 30 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions DAGͷ֤௖఺͔Β࣍ͷ௖఺΁஋Λ౉ͨ͢Ίʹ࢖͑Δػೳ

Slide 31

Slide 31 text

• ओʹ੒Ռ෺ΛӬଓԽ͢ΔͨΊʹػೳ͢ΔArtifactsͱɺҰ࣌తͳΩϟογϡΛWorkflowؒͰڞ༗ͯ͠WorkflowΛߴ଎Խ ͢ΔͨΊͷCachingͱ͍͏ػೳ͕͋Δ • ͦΕͧΕ actions/(upload/download)-artifactͱactions/cacheͱ͍͏ActionͰػೳ͕ఏڙ͞Ε͍ͯΔɻ • ࣮͸্هͷػೳΛ࣮ݱ͢ΔͨΊͷʮArtifactͷμ΢ϯϩʔυʯҎ֎ͷAPI͸υΩϡϝϯτʹܝࡌ͞Ε͍ͯͳ͍ • Artifacts΋Caching΋GitHub ActionsͷRunner্Ͱ࢖͏͜ͱͷΈΛ૝ఆ͍ͯ͠ΔͨΊͩͱࢥΘΕΔ • ࢓૊Έͱͯ͠͸Runner্Ͱ͚ͩఏڙ͞ΕΔ ACTIONS_RUNTIME_TOKEN Λ࢖ͬͯΞοϓϩʔυઌͷҰ࣌URLΛऔ ಘ͠ɺͦͷҰ࣌URLʹରͯ͠Ξοϓϩʔυ͢Δ • https://github.com/actions/toolkit/blob/d1abf7dc74ea38ed6c5552491cdf8b695b813722/packages/cache/ src/internal/cacheHttpClient.ts#L35-L38 • https://github.com/actions/toolkit/blob/d1abf7dc74ea38ed6c5552491cdf8b695b813722/packages/artifact/ src/internal/utils.ts#L215-L219 31 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions ༨ஊ: ArtifactsͱCaching

Slide 32

Slide 32 text

32 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions • ؀ڥม਺ GITHUB_* • GITHUB_EVENT_PATHʹ͋ΔJSONϑΝΠϧ಺ʹΠϕϯτΛ ϑοΫͨ͠ࡍͷϦΫΤετϖΠϩʔυ͕͋Δ • ্هΛ࢖͏͜ͱͰStepͷॲཧ্ͰWorkflowͷίϯςΩετʹ ͦͬͨಈ͖Λ͢Δ͜ͱ͕Ͱ͖Δ Step಺Ͱ͸؀ڥม਺͔ΒGitHub Actionsͷ৘ใΛऔಘՄೳ

Slide 33

Slide 33 text

33 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions “GitHub Actions Deep Dive using PHP”

Slide 34

Slide 34 text

34 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions • https://github.com/k1LoW/github-script-php • actions/github-scriptͷPHP൛Action • Step಺Ͱ uses: Ͱݺͼग़͢͜ͱͰಛʹԿ΋༻ҙͤͣʹPHPεΫϦ ϓτΛॻ͘͜ͱ͕Ͱ͖Δʢsetup-php΋͍Βͳ͍ʣ • طʹೝূࡁΈͷ knpkabs/github-api ͷΫϥΠΞϯτΠϯελϯε ͕ $github ʹηοτࡁΈɻͳͲ actions/github-scriptʹ͍ۙಈ͖ Λ͢Δ • PHPerKaigi2022ͷͨΊʹ࡞Γ·ͨ͠ ೚ҙͷStepͰPHPεΫϦϓτΛ࣮ߦͰ͖ΔAction

Slide 35

Slide 35 text

35 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions GITHUB_EVENT_PATHͷJSONΛdumpͯ͠ΈΔ • uses: k1LoW/github-script-php@v0 Ͱݺͼग़͚ͩ͢ • uses: actions/checkout@v3 ΋͍Βͳ͍

Slide 36

Slide 36 text

36 ϫʔΫϑϩʔΤϯδϯͱͯ͠ͷGitHub Actions ͍Ζ͍Ζ৘ใ͕औಘͰ͖Δͷ͕Θ͔Δ

Slide 37

Slide 37 text

37 Action

Slide 38

Slide 38 text

Action 38 An action is a custom application for the GitHub Actions platform that performs a complex but frequently repeated task. https://docs.github.com/en/actions/learn-github-actions/ understanding-github-actions Action͸ɺGitHub Actions ϓϥοτϑΥʔϜͷͨΊͷΧελϜ ΞϓϦέʔγϣϯͰɺෳࡶ͕ͩසൟʹ܁Γฦ͞ΕΔλεΫΛ࣮ ߦ͢Δ΋ͷͰ͢ɻ

Slide 39

Slide 39 text

39 Action • Runner͸VM͕ͩJobͷ࣮ߦΛऴ͑ΔͨͼʹॳظԽ͞ΕΔ • Provide a clean instance for every job execution. • Runner΋VMͷ؀ڥ΋OSSͱͯ͠ެ։͞Ε͍ͯΔ • https://github.com/actions/runner • https://github.com/actions/virtual-environments RunnerʢGitHub-hosted runnersʣ

Slide 40

Slide 40 text

40 Action • Jobͷ࣮ߦ؀ڥ͸େ͖͘3௨Γ͋Δ 1. શͯͷStepΛ௚઀Runner্Ͱ࣮ߦ͢Δ 2. શͯͷStepΛ1छྨͷDockerΠϝʔδΛ࢖ͬͨDocker on Runner্ͰVMͷҰ෦σΟϨΫτϦΛϚ΢ϯτͨ͠͏͑Ͱ࣮ ߦ͢Δ 3. Ұ෦ͷStepΛRunner্ͰɺҰ෦·ͨ͸શͯͷStepΛ1छྨ Ҏ্ͷDockerΠϝʔδΛ࢖ͬͨDocker on Runner্ͰVM ͷҰ෦σΟϨΫτϦΛϚ΢ϯτͨ͠͏͑Ͱ࣮ߦ͢Δ Runner্ͷJobͷ࣮ߦ؀ڥ

Slide 41

Slide 41 text

• ௨ৗͷJob • શͯͷStep͕ಉ͡؀ڥɻsetup-phpͳͲ΋ɺ౎౓RunnerʹPHPΛΠϯετʔϧ͍ͯ͠ Δ 41 Action 1. શͯͷStepΛ௚઀Runner্Ͱ

Slide 42

Slide 42 text

• jobs..container: Λࢦఆ͢Δ͜ͱͰ೚ҙͷίϯςφ্ͰJobΛ࣮ߦͰ͖Δ • ࠷ॳ͔Βඞཁͳ΋ͷ͕༻ҙ͞Εͨίϯςφ؀ڥͰ࣮ߦ͕Մೳ 42 Action 2. શͯͷStepΛ1छྨͷDockerΠϝʔδΛ࢖ͬͨDocker on Runner্Ͱ

Slide 43

Slide 43 text

• ϫʔΫϑϩʔߏจ্ʹ͸ͳ͍Job࣮ߦ؀ڥ • …ͷΑ͏ʹݟ͑Δ͕࣮͸ଘࡏ͢Δ 43 Action 3. Ұ෦ͷStepΛRunner্ͰɺҰ෦·ͨ͸શͯͷStepΛ1छྨҎ্ͷDockerΠϝʔδΛ࢖ͬͨDocker on Runner্Ͱ

Slide 44

Slide 44 text

44 Action • Actionͷ࣮૷ʹΑͬͯ͸3छྨʹ෼͔ΕΔɻ3छྨͱ΋VM্ʹAction ͷϦϙδτϦ͕Clone͞ΕΔͷ͸ಉ͡ 1. JavaScript action • جຊͷ࣮૷ํ๏ɻJavaScriptͰॲཧΛॻ͘ɻRunner্ʹ͋ ΔNodeΛ࢖ͬͯͦͷJavaScriptΛ࣮ߦ͢Δ 2. Docker container action • ࢦఆ͞ΕͨDockerfileΛDocker on Runnerͱ࣮ͯ͠ߦ͢Δ 3. Composite action • action.ymlʹهࡌ͞Εͨ steps: ΛॱʹRunner্Ͱ࣮ߦ͢Δ Actionͷछྨ

Slide 45

Slide 45 text

Action 45 ͲͷλΠϓͷActionͰ΋೚ҙͷDockerΠϝʔδΛ࢖༻Ͱ͖Δ • DockerΛ࢖༻͢ΔActionΛ࢖༻͢Δ͜ͱͰ3ͭ໨ͷJobͷ࣮ߦ؀ڥ ͷύλʔϯΛ࣮ݱ͍ͯ͠Δ • Runnerʹ͸dockerd͕͍Δͷ͔ͩΒͲ͏ͱͰ΋ͳΔɻ 1. JavaScript action • JavaScriptͰDockerίϚϯυΛ࣮ߦ͢Ε͹ྑ͍ 2. Docker container action • DockerΠϝʔδΛ؆୯ʹ࢖༻͢ΔActionͱߟ͑ΒΕΔ 3. Composite action • steps: ্ͰDockerίϚϯυΛ࣮ߦ͢Ε͹ྑ͍

Slide 46

Slide 46 text

46 Action “GitHub Actions Deep Dive using PHP”

Slide 47

Slide 47 text

• ͭ·ΓʮPHPͷDockerΠϝʔδΛ࢖͏ʯͱ͍͏͜ͱ • DockerΠϝʔδΛ࢖͏͜ͱͰ೚ҙͷStepͰPHPΛ͔ͭͬͨॲཧΛॻ͘͜ͱ͕Ͱ͖Δ • ͦͷॲཧΛActionͱͯ͠੾Γग़ͯ͠ఏڙ͢Δ 47 Action PHPͰActionΛ࡞Δ

Slide 48

Slide 48 text

• ੩తղੳπʔϧPhanΛఏڙ͢ΔAction • PhanΛબఆͨ͠ཧ༝ • php-ast͕ඞཁͰ؀ڥߏங͕গ͠໘౗ͳଆ໘͕͋ΔͨΊʢٯʹActionΛ࡞Δϝ Ϧοτ͕͋Γͦ͏ʣ • PHPStanͱPsalmͷAction͸ݟ͔͕ͭͬͨPhan͸ͳ͔ͬͨͨΊ • Docker container actionͰ࡞Δ 48 Action phan-actionΛ࡞ͬͯΈΔ

Slide 49

Slide 49 text

• ActionͷઃఆϑΝΠϧ • ίϯϑΟάϑΝΠϧͷύεͷ೚ҙࢦ ఆͱPhan࣮ߦ࣌ͷexit statusΛແࢹ ͢ΔͨΊͷઃఆΛ௥Ճ Action 49 action.yml

Slide 50

Slide 50 text

Action • Phan͕Πϯετʔϧ͞Ε͍ͯΔPHP ίϯςφΛ࡞੒͢ΔͨΊͷDockerfile • ͱΓ͋͑ͣPhan͕࣮ߦͰ͖Ε͹͍͍ ͷͰglobalʹΠϯετʔϧ 50 Dockerfile

Slide 51

Slide 51 text

Action • جຊతʹPhanΛ࣮ߦ͢Δ͚ͩ 51 entrypoint.sh

Slide 52

Slide 52 text

• https://github.com/k1LoW/phan-action • uses: Ͱݺͼग़͚ͩ͢ͰPhanΛ೚ҙͷ ϓϩδΣΫτʹ࣮ߦՄೳ • Phanͷ؀ڥ͸Dockerίϯςφʹดͯ͡ ͍ΔͷͰPHP5؀ڥͳRunnerͰ΋ద༻ Ͱ͖Δ • PHPerKaigi2022ͷͨΊʹ࡞Γ·ͨ͠ Action 52 k1LoW/phan-action

Slide 53

Slide 53 text

53 Action ੩తղੳͰ͖ͨ

Slide 54

Slide 54 text

͓ΘΓʹ 54

Slide 55

Slide 55 text

• GitHubϦϙδτϦͷΞϓϦέʔγϣϯίʔυͷCI/CD؀ڥͱͯ͠΋ਃ͠෼ͳ͍͕ɺͦΕ͚ͩ Ͱ͸ͳ͍ • ͞·͟·ͳΠϕϯτͰτϦΨʔͰ͖ΔϫʔΫϑϩʔΤϯδϯͱͯ͠ΈΔͱ׆༻ൣғ͸޿͕Δ • Action΋ඇৗʹ؆୯ʹ࡞ΕΔɻʢ͋ΔҙຯʣPHPͰ΋࡞ΕΔɻ • ࠓճ࿩͍ͤͯͳ͍͜ͱ΋ଟ਺ɻ • jobs..services: ΍ ACTIONS_RUNNER_DEBUG ΍ OIDC ΍ ηΩϡϦςΟͳ Ͳ • GitHub Actions͸Ԟ͕ਂ͍ɻGitHub ActionsͰ͓࿩͠͠·͠ΐ͏ɻ 55 ͓ΘΓʹ GitHub Actions͸Ԟ͕ਂ͍

Slide 56

Slide 56 text

Thank You! Thank You! 56