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

脱初心者のための GitHub Actions

yuki
January 13, 2022

脱初心者のための GitHub Actions

「GitHub Actionsって聞いたことあるけど、よく理解していない」
「知ってるけど使ったことない」
という方向けの内容です。

yuki

January 13, 2022
Tweet

More Decks by yuki

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • ஑ా ༗ًক / Yukimasa Ikeda • 1994೥ੜ·Ε ਆಸ઒ݝԣ඿ࢢग़਎

    • 2015/04ʙ2018/12 ધһ • 2019/06ʙ2021/08 ΤϯδχΞ • Rails, iOS, Android, Laravel, React, Next.js
  2. GitHub Actionsͱ͸ʁ 6 • CI/CDͷαʔϏε • ϦϙδτϦͱ࿈ܞ͠ɺϏϧυɾ 
 ςετɾσϓϩΠΛࣗಈԽͤ͞Δ •

    GitHubͷϑΝʔετύʔςΟ੡ ͳͷͰIssue΍PRͱͷ࿈ܞ͕Մೳ GitHub Actionsͷಛ௃
  3. GitHub Actionsͷ࢖͍ํ 13 ϫʔΫϑϩʔͷ࡞੒ • ϦϙδτϦʹ .github/workflows ͱ͍͏σΟϨΫτϦΛ࡞੒͠ɺ ͦͷ௚Լʹ .yml

    ͔ .yaml ͱ͍͏֦ுࢠͰϫʔΫϑϩʔͷઃఆϑΝ ΠϧΛ࡞੒ • ϑΝΠϧ໊͸ࣗ༝ • ϫʔΫϑϩʔ͝ͱʹෳ਺ϑΝΠϧΛ࡞੒͢Δ͜ͱ΋Մೳ
  4. name: learn-github-actions on: [push ] jobs : check-bats-version : runs-on:

    ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v GitHub Actionsެࣜͷαϯ ϓϧͷϫʔΫϑϩʔ GitHub Actionsͷ࢖͍ํ ެࣜͷwork fl ow
  5. name: learn-github-actions on: [push ] jobs : check-bats-version : runs-on:

    ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v GitHubϦϙδτϦʹදࣔ͞ ΕΔϫʔΫϑϩʔͷ໊લɻ লུՄೳͰɺলུ͢Δͱ૬ ରύε໊͕લͱͳΔɻ GitHub Actionsͷ࢖͍ํ name:
  6. name: learn-github-actions on: [push ] jobs : check-bats-version : runs-on:

    ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v ඞਢ 
 τϦΨʔͱͳΔΠϕϯτͷ ໊લɻ 1ͭͷΠϕϯτ΋͘͠͸ෳ਺ ͷΠϕϯτΛࢦఆ͢Δ͜ͱ ͕Ͱ͖Δɻ GitHub Actionsͷ࢖͍ํ on:
  7. name: learn-github-actions on: [push, pull_request ] jobs : check-bats-version :

    runs-on: ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v ෳ਺ͷ৔߹͸഑ྻͰࢦఆ͢ Δ͜ͱ͕Մೳɻ GitHub Actionsͷ࢖͍ํ on:
  8. name: learn-github-actions on : push : branches : - main

    pull_request : branches : - main jobs : check-bats-version : runs-on: ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v Πϕϯτ͝ͱʹઃఆΛߦ͏ ৔߹͸ɺͦΕͧΕͷΠϕϯ τʹରͯ͠ઃఆ͢Δඞཁ͕ ͋Δɻ ઃఆ͕ͳ͍Πϕϯτ΋ؚΊ ίϩϯʢ:ʣΛ௥Ճ͢Δ GitHub Actionsͷ࢖͍ํ on:
  9. name: learn-github-actions on: [push ] jobs : check-bats-version : runs-on:

    ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v ϫʔΫϑϩʔϑΝΠϧͰ࣮ ߦ͞ΕΔશͯͷδϣϒΛά ϧʔϓԽ͢Δɻ 
 sampleͰ͸
 check-bats-versio n ͱ͍͏໊લͷJobΛ1͚ͭͩ ఆ͍ٛͯ͠Δɻ GitHub Actionsͷ࢖͍ํ jobs:
  10. name: learn-github-actions on: [push ] jobs : check-bats-version : runs-on:

    ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v ඞਢ Ծ૝Ϛγϯͷࢦఆɻ sanpleͰ͸Ubuntu LinuxͰ ࣮ߦ͢ΔΑ͏ʹઃఆΛͯ͠ ͍Δ GitHub Actionsͷ࢖͍ํ run-on:
  11. name: learn-github-actions on: [push ] jobs : check-bats-version : runs-on:

    ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v ίϚϯυΛ࣮ߦͰ͖Δλε Ϋɻ Կ͔͠ΒͷίϚϯυΛ࣮ߦ ͢Δ͔ɺԿ͔͠ΒͷΞΫ γϣϯΛݺͼग़͢ɻ uses͸ΞΫγϣϯɺ 
 run͸ίϚϯυΛࢦఆ͢Δɻ GitHub Actionsͷ࢖͍ํ steps:
  12. name: learn-github-actions on: [push ] jobs : check-bats-version : runs-on:

    ubuntu-latest steps : - name: First step uses: actions/checkout@v 2 - name: Setup node uses: actions/setup-node@v 1 - name: Install bats run: npm install -g bat s - name: Bats version run: bats -v step͸GitHubͰදࣔ͞ΕΔ ໊લΛ͚ͭΔ͜ͱ͕Ͱ͖ Δɻ GitHub Actionsͷ࢖͍ํ steps:
  13. ϦϙδτϦΛ࡞੒࣮ͯ͠ࡍʹ֬ೝͯ͠ΈΔ # ϦϙδτϦΛ࡞੒ $ mkdir github-actions-sampl e $ cd github-actions-sampl

    e # ࢦఆͷσΟϨΫτϦΛ࡞੒ $ mkdir -p .github/workflow s # ϫʔΫϑϩʔΛ࡞੒ $ vi .github/workflows/learn-github-actions.ym l # pushͯ͠ActionsΛ֬ೝ͢Δ $ git ini t $ git add . $ git commit -m "Initial commit " $ git remote add origin [ϦϙδτϦurl ] $ git push -u origin main name: learn-github-actions on: [push ] jobs : check-bats-version : runs-on: ubuntu-latest steps : - uses: actions/checkout@v2 - uses: actions/setup-node@v1 - run: npm install -g bats - run: bats -v