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

GitHubにおける GitHub Actions利用法/How GitHub uses GitHub Actions

GitHubにおける GitHub Actions利用法/How GitHub uses GitHub Actions

CI/CD Test Night #5 発表資料
https://testnight.connpass.com/event/145238/

Yuichi Tanaka

October 02, 2019
Tweet

More Decks by Yuichi Tanaka

Other Decks in Programming

Transcript

  1. @yuichielectric
    CI/CD Test Night #5
    GitHubʹ͓͚Δ
    GitHub Actionsར༻๏

    View full-size slide

  2. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    Who am I?
    ాத ༟Ұ (yuichielectric)

    Solutions Engineer, GitHub


    View full-size slide

  3. GitHub Actions

    View full-size slide

  4. GitHub಺ʹ૊ΈࠐΈ


    20δϣϒ·Ͱฒߦ࣮ߦ͕Մೳ

    ʢϦϙδτϦ͋ͨΓʣ

    Linux, macOS, WindowsʹՃ͑ίϯςφ
    ͷ࣮ߦ΋Մೳ


    ϚτϦοΫεϏϧυ


    ࣮ߦதӾཡՄೳɺݕࡧɺ֤ߦ͕ϦϯΫԽ

    ͞Εͨϩά

    View full-size slide

  5. https://github.com/ruby/ruby/actions

    View full-size slide

  6. ॲཧΛίϯϙʔωϯτԽʢactionsͱݺͿʣ
    ͯ͠࠶ར༻͢Δࣄ͕Մೳ 

    - Dockerίϯςφ

    - JavaScript

    ༷ʑͳΠϕϯτͰτϦΨʔՄೳ

    - GitHub্ͷ͢΂ͯͷWebhookΠϕϯτ

    - cronه๏ʹΑΔఆظ࣮ߦ

    - HTTPϦΫΤετ

    View full-size slide

  7. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    1 name: CI Build
    2 on: [push, pull_request]
    3 jobs:
    4 build:
    5 runs-on: ${{ matrix.os }}
    6 strategy:
    7 matrix:
    8 os: [ubuntu-latest, windows-latest, macOS-latest]
    9 node-version: [8.*, 10.*, 12.*]
    10 steps:
    11 - name: Checkout the changes from Git
    12 uses: actions/checkout@v1
    13 - name: Use Node.js
    14 uses: actions/setup-node@v1
    15 with:
    16 node-version: ${{ matrix.node-version }}
    17 - name: Install dependencies
    18 run: npm ci
    19 - name: Execute tests
    20 run: npm test
    21 - name: Record code coverage
    22 run: npx codecov
    23 env:
    24 CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

    View full-size slide

  8. https://github.com/marketplace?type=actions

    View full-size slide

  9. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    GitHubࣾ಺Ͱͷར༻ #1
    - ύοέʔδϦϦʔεͷࣗಈԽ -
    https://github.com/github/learning-lab-components

    View full-size slide

  10. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    •τϦΨʔ: master΁ͷϚʔδ

    1. υϥϑτϦϦʔεϊʔτʹ௥ه

    2. package.jsonʹهࡌͷόʔδϣϯ্͕͕͍ͬͯͨΒϦϦʔεϊʔτΛpublish

    3. όʔδϣϯ൪߸͕ηϚϯςΟοΫόʔδϣχϯάʹै͍ͬͯΔ͔Ͳ͏͔νΣοΫ

    4. GitHub Package RegistryʹύοέʔδΛpublish

    https://github.com/github/learning-lab-components/blob/master/.github/workflows/release_management.yml
    ϫʔΫϑϩʔͷྲྀΕ

    View full-size slide

  11. https://github.com/github/learning-lab-components/releases

    View full-size slide

  12. https://github.com/github/learning-lab-components/packages/11396

    View full-size slide

  13. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    1. υϥϑτϦϦʔεϊʔτʹ௥ه

    release-drafter

    https://github.com/toolmantim/release-drafter

    2. package.jsonʹهࡌͷόʔδϣϯ্͕͕͍ͬͯͨΒϦϦʔεϊʔτΛpublish

    node-draft-releaser

    https://github.com/JamesMGreene/node-draft-releaser

    3. όʔδϣϯ൪߸͕ηϚϯςΟοΫόʔδϣχϯάʹै͍ͬͯΔ͔Ͳ͏͔νΣοΫ

    validate-semver-release

    https://github.com/JasonEtco/validate-semver-release

    4. GitHub Package RegistryʹύοέʔδΛpublish

    npm publishίϚϯυΛ࣮ߦ

    https://github.com/github/learning-lab-components/blob/master/.github/workflows/release_management.yml
    ϫʔΫϑϩʔͷྲྀΕ

    View full-size slide

  14. https://github.com/toolmantim/release-drafter

    View full-size slide

  15. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    GitHubࣾ಺Ͱͷར༻ #2
    - ΢ΣϒαΠτͷը૾αΠζͷ࠷దԽ -
    https://github.com/customer-stories
    ϦϙδτϦ͸privateͰ͢ ><

    View full-size slide

  16. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    •τϦΨʔ: push, pull-request

    1. ࠩ෼தͷը૾ϑΝΠϧͷαΠζΛνΣοΫ͠ɺҰఆ஋Ҏ্ͷαΠζͷը૾

    ͸ॖখͯ͠commit & push

    2. ϓϧϦΫΤετʹαΠζͷࠩ෼ͷίϝϯτΛ౤ߘ

    ϫʔΫϑϩʔͷྲྀΕ

    View full-size slide

  17. https://github.com/calibreapp/image-actions

    View full-size slide

  18. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    1 name: Compress images
    2 on: pull_request
    3 jobs:
    4 build:
    5 name: calibreapp/image-actions
    6 runs-on: ubuntu-latest
    7 steps:
    8 - uses: actions/checkout@master
    9 - name: calibreapp/image-actions
    10 uses: docker://calibreapp/github-image-actions
    11 env:
    12 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    View full-size slide

  19. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    ࠓޙͷ༧ఆ

    View full-size slide

  20. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    2019/11/13ʹGA༧ఆ

    View full-size slide

  21. Self hosted runner

    ࣗ͝਎ͷϋʔυ΢ΣΞ/VM্Ͱͷ࣮ߦ
    ۙʑఏڙ։࢝༧ఆ

    View full-size slide

  22. https://twitter.com/natfriedman/status/1178321206321143808

    View full-size slide

  23. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    • UIͷվળ

    • γϯλοΫεͷ௥Ճ

    • ϒϥ΢β্ͰYAMLϑΝΠϧΛฤू͢ΔࡍͷΦʔτίϯϓϦʔτɺΤϥʔදࣔ

    • υΩϡϝϯτͷվળ
    ͦͷଞӶҙ։ൃத

    View full-size slide

  24. https://github.com/features/actions

    View full-size slide

  25. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    Tips

    View full-size slide

  26. CI/CD Test Night #5
    GitHubʹ͓͚ΔGitHub Actionsར༻๏
    ϫʔΫϑϩʔϑΝΠϧͷݕࡧ

    View full-size slide