Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
はてなにおけるGitHub Actions活用事例 / GitHub Actions in H...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
papix
January 26, 2021
Technology
2.8k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
はてなにおけるGitHub Actions活用事例 / GitHub Actions in Hatena
papix
January 26, 2021
More Decks by papix
See All by papix
Houtou.pm #1
papix
0
1.9k
Perl歴約10年のエンジニアがフルスタックTypeScriptに出会ってみた
papix
1
740
YAPC::Kyotoの「全て」 / All of "YAPC::Kyoto"
papix
0
1.7k
イベントの中の人 / Inside the Events
papix
0
360
2022年に始めるPerlでWebサービス開発(趣味)
papix
0
630
ワーケーションに関する考察
papix
3
2.3k
(今更)Amplifyさっくり体験
papix
0
930
ミススペルを発見するmisspellのご紹介 / Introduce misspell
papix
0
1.3k
「知らなかった」を聞きに行く 〜海外カンファレンス参加のススメ〜 / builderscon 2019
papix
0
380
Other Decks in Technology
See All in Technology
Djangoユーザが知っ得なPostgreSQL機能 - 設計の選択肢を増やす / Djang-use-PostgreSQL
soudai
PRO
1
230
NAB Show 2026 動画技術関連レポート / NAB Show 2026 Report
cyberagentdevelopers
PRO
0
170
Disciplined Vibes: Scaling AI-Assisted Engineering
sheharyar
0
140
新しいVibe Codingと”自走”について
watany
6
300
Microsoft Build Keynoteふりかえり
tomokusaba
0
120
2026TECHFRESH畢業分享會 - 葬送的通靈師:化系統與用戶雜訊成行動訊號
line_developers_tw
PRO
0
880
フロンティアAIのゲート化と地政学リスク
nagatsu
0
130
プロダクト開発から業務改善コンサルまで。事業全体へ「染み出す」ことで広がるエンジニアの可能性
ham0215
0
110
連合学習と機密コンピューティング
lycorptech_jp
PRO
0
110
"何を作るか"を任される エンジニアは、どう育つのか
yutaokafuji
1
610
AIはどのように 組織のアジリティを変えるのか?
junki
1
520
Bucharest Tech Week 2026 - Reinventing testing practices in the AI era
edeandrea
PRO
1
150
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Agile that works and the tools we love
rasmusluckow
331
21k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
The Spectacular Lies of Maps
axbom
PRO
1
800
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
The untapped power of vector embeddings
frankvandijk
2
1.8k
YesSQL, Process and Tooling at Scale
rocio
174
15k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
200
Transcript
ͯͳͰͷ GitHub Actions׆༻ࣄྫ CI/CD׆༻ࣄྫˍTIPSൃදձ id:papix (גࣜձࣾͯͳ)
ࣗݾհ • papix (id:papix / @__papix__) • גࣜձࣾͯͳ WebΞϓϦέʔγϣϯΤϯδχΞ (2017ʙ)
• ϒϩάMediaνʔϜ → ϚϯΨνʔϜ • Ұൠࣾஂ๏ਓJapan Perl Associationཧࣄ • ϒϩά: https://papix.hatena(blog.(com|jp)|diary.jp)
ࠓ͢͜ͱ • ňͯͳͰͷGitHub Actions׆༻ࣄྫʼn • 2ͭͷαʔϏεΛࡐʹͯ͠, ҎԼʹ͍ͭͯ͠·͢: • GitHub ActionsͷҠߦ,
ͦͷதͷ, ίετܭࢉ • GitHub ActionsͷϝϦοτ/σϝϦοτ • ͓͠ΖςΫ
ࡐ
ͯͳϒϩά
ͯͳϒϩάMedia
GigaViewer • ࣾͰ։ൃ͍ͯ͠ΔϚϯΨϏϡʔϫ • ϒϥβͰອըΛಡΉͨΊͷػೳΛఏڙ • Ϗϡʔϫ / τοϓϖʔδ /
ݕࡧը໘ / ཧը໘ ... • ग़൛༷͚ࣾʹఏڙ • 11ࣾ / 13ͷαΠτͰ࠾༻
গδϟϯϓʴ גࣜձࣾूӳ༷ࣾ (https://shonenjumpplus.com/)
ίϛοΫDAYS גࣜձࣾߨஊ༷ࣾ (https://comic-days.com/)
ίϛοΫϒγϩʔυ WEB גࣜձࣾϒγϩʔυϝσΟΞ༷ (https://comicbushi-web.com/)
͜Ε·Ͱͷ͋Β͢͡
ैདྷͷCIڥ • EC2্ʹߏஙͨ͠Jenkins • ։ൃʹؾΛऔΒΕͯ, Ͳ͏ͯ͠อकཧ͕ޙճ͠ʹ͞Ε͕ͪ.. • ྺ࢙తܦҢʹΑΓ, ಉ࣌ʹ࣮ߦͰ͖ͳ͍ςετ •
ಉ࣌ʹͨ͘͞Μͷpush͕ߦΘΕΔͱ, ςετ͕ऴΘΔ·Ͱे ͭඞཁ...
GitHub.comԽͱGitHub Actionsͷొ • ͦͷࠒ, GitHub EnterpriseΛGitHub.comʹஔ͖͑Δಈ͖͕͋ͬͨ • ͦͷྲྀΕͷதͰ, GitHub Actionsొ͖ͯͨ͠
• ň͜Ε͏͔͠ͳ͍!!!ʼn • ...ͱ͍͏͜ͱͰ, ࠷େͷωοΫͩͬͨňςετʼnͷGitHub ActionsԽ ͔ΒऔΓΉ͜ͱʹͨ͠
GitHub Actionsͱ?
GitHub Actions • GitHub͕ఏڙ͢ΔCI/CDڥ • Linux, macOS, WindowsڥʹରԠ • GitHub
ActionsͰͷॲཧϫʔΫϑϩʔΛॻ͘ࣄͰఆٛ • ϦϙδτϦͷ .github/work f l ow σΟϨΫτϦʹYAMLͰهड़
GitHub Actions • GitHubͱ"ྑ͍ҙຯͰ"ີ݁߹͍ͯ͠Δ • pushͨ͠Βଈ࠲ʹॲཧΛ࣮ߦͯ͘͠ΕΔ • ྉۚ • Linuxͷ߹,
1͋ͨΓ $0.008 • GitHub Enterprise CloudͳΒ݄50,000ͷແྉ͋Γ
ςετͷGitHub ActionsԽ
։ൃڥͷDockerԽ • ࠷ॳʹ։ൃڥΛDockerԽ͓͖ͯ͠·͠ΐ͏ • ࣗͷPCͰςετ͕DockerͰ݁͢Ε, GitHub ActionsͰ ςετͪΌΜͱಈͣ͘! •
docker-compose.yml ʹඞཁͳϛυϧΣΞͳͲͷఆٛΛॻ͍ͯ, docker-compose run ͰςετΛ࣮ߦͰ͖ΔΑ͏ʹ͢Δ
ϫʔΫϑϩʔͷߏங • ։ൃڥͷDockerԽ͕͍ྃͯ͠Ε, ͦ͏͘͠ͳ͍ͣ • ΠϝʔδΛϏϧυͯ͠, docker-compose runͰςετΛ࣮ߦͯ͠...
GitHub ActionsԽ ʙʙ
...ͱ, ؆୯ʹ͍͔ͳ͍ • ͍Ζ͍Ζߟ͑Δࣄ͕͋Δ! • ςετͷ࣌ؒΛͳΔ͘͘͢Δ • ίετͷࢼࢉ • Jenkins͔Βͷஔ͖͑࡞ઓ
• etc...
࣮ߦ࣌ؒͷݮ
DockerͷΠϝʔδϏϧυ͠ͳ͍ • ňͦΓΌͦ͏ͩ!ʼnͱ͍͏ײ͡Ͱ͕͢... • ։ൃڥͷdocker imageΛECRʹొͯ͠, ςετ͢Δ͝ͱʹ pull͢Δͱ͍͏࡞ઓ͕͑Δ
ECR͔Β pull͢Δྫ name: tes t on : pull_request : jobs
: test : - uses: actions/
[email protected]
. 4 - name: Configure AWS Credential s uses: aws-actions/configure-aws-
[email protected]
. 5 with: .. . - name: Login to Amazon EC R uses: aws-actions/
[email protected]
. 1 - name: Pull from EC R run: docker pull ...
ςετͦͷͷʹ͕͔͔࣌ؒΔ • GitHub ActionsAzureͷStandard_DS2_v2্Ͱಈ࡞͢Δ • εϖοΫvCPU 2, ϝϞϦ 7GB •
ී௨ʹςετΛճ͢ͱ, 1࣌ؒܦաͯ͠ऴΘΒͳ͍...
࡞ઓ • ͦ͜Ͱ, ࣍ͷΑ͏ͳ࡞ઓΛߟ͑·ͨ͠: • self-hosted runnerΛ͏ • AWS CodeBuildΛ͏
self-hosted runner • ͕ࣗ࡞ͬͨڥͰGitHub ActionsͷॲཧΛ࣮ߦͰ͖ΔΈ • ඞཁͳڥΛߏஙͯ͠, GitHubʹొ͢Δͱར༻Ͱ͖Δ • ϦϙδτϦ/Organization/EnterpriseͷϨϕϧͰڞ༗Ͱ͖Δ
• ੲϦϙδτϦ୯ҐͰ͔͠ొ͕ग़དྷͳ͔ͬͨهԱ͕͋Δ
self-hosted runner • self-hosted runnerجຊతʹىಈͬ͠ͺͳ͠ • = ॲཧΛ͍ͯ͠ͳͯ͘ίετ͕͔͔Δ • self-hosted
runner 1ʹ͖ͭ1ͭͷॲཧ͔͠ग़དྷͳ͍ • ෳͷॲཧΛ͚ͨ͠Ε, ෳͷself-hosted runner͕ඞཁ
AWS CodeBuild • AWS CodeBuildͳΒ, vCPU 32, ϝϞϦ144GBͷڥ͕͋Δ! • self-hosted
runnerͱҧ͍, ࣮ߦ/՝ۚ • ͨͩ, ňGitHub Actions͔ΒAWS CodeBuildΛىಈʼnͲ͏ͳͷ͔? • ͩͬͨΒňJenkins͔ΒAWS CodeBuildΛىಈʼnͰྑ͘ͳ͍? • ߋʹݴ͑ňAWS CodePipelineʼnͰྑ͘ͳ͍???
͏1ͭͷબࢶ • ňTravisCI ͰૈࡶʹςετΛׂ࣮ߦ͢Δʼn • https://ssig33.com/text/distributed_test_on_TravisCI • ͭ·ΓͲ͏͍͏͜ͱ͔ͱݴ͏ͱ...
ςετΛ16ׂ!!!!!
ϏϧυϚτϦοΫεͷ׆༻ • GitHub ActionsʹňϏϧυϚτϦοΫεʼnͱ͍͏֓೦͕͋Δ • ຊདྷ, Perlͷ5.32ܥ, 5.30ܥ, 5.28ܥ... ͷΑ͏ʹ,
ෳͷڥͰಉ࣌ ʹςετΛ࣮ߦ͢ΔͨΊͷͷ • ͜ΕΛͬͯ, ςετΛ16ׂ࣮ͯ͠ߦ͢Δ!!! • ίετવ16ഒ͕ͩ, ͦͷૉૣ͘ऴΘΔͷͰेʹϖΠ͢Δ
ϏϧυϚτϦοΫεͷ׆༻ • ϏϧυϚτϦοΫεͱͯ͠࿈൪Λࢦఆ • = ࿈൪ͷ͚ͩςετΛׂ࣮ͯ͠ߦ͢Δ • ྫ͑1͔Β16·Ͱͷ࿈൪ͳΒ, 16ׂ •
f i ndΛͬͯςετରͷҰཡΛऔಘ → splitͰׂ → ࣮ߦ • ҙͱͯ͠, ςετΛׂ͢Δ݁ՌႈͰͳ͚ΕͳΒͳ͍
ϫʔΫϑϩʔͷ ༷ࢠ jobs : test : strategy : # ׂͨ͠ςετͷ͏ͪ,
1͕ͭίέͯଞͷશͯΛcancel͠ͳ͍Α͏ʹ͢Δ fail-fast: fals e matrix : test_id: ["01", "02", "03"] # ࿈൪Λࢦఆ steps : ... ॾʑͷ४උ .. . # findͱsplitΛͬͯ, ςετରͱͳΔϑΝΠϧ໊͕ॻ͔Εͨ # test01, test02, test03 ͱ͍͏ϑΝΠϧΛ࡞ - name: Split tests into chunk s run: | find t -name "*.t" -not -type d > test_files.tx t split -n r/${{ strategy.job-total }} \ --numeric-suffixes=1 \ --elide-empty-files test_files.txt tes t # ↑Ͱ࡞ͬͨ test01, test02, test03ͷ͍ͣΕ͔Λରͱͯ͠ # ςετΛ࣮ߦ͢Δ - name: tes t run: | docker-compose run --rm --no-deps app \ carton exec -- prove < test${{ matrix.test_id }} ※ 3ׂͷྫ
prepareδϣϒͷ༻ҙ • ςετΛ࣮ߦ͢Δʹ͋ͨͬͯඞཁͳॲཧprepareδϣϒʹԡ͠ࠐΉ • 16ׂͨ͠ςετͦΕͧΕͰ࣮ߦ͢ΔͱඇޮͳͨΊ • ςετprepareϑΣΠζޙʹ࣮ߦ͢ΔΑ͏ʹ͢Δ • prepareδϣϒͰ༻ҙͨ͠ϑΝΠϧ, ଞͷδϣϒͰͦͷ··͑ͳ͍
• ͋Δδϣϒͱผͷδϣϒ, ผͷڥͰॲཧ͕࣮ߦ͞ΕΔͨΊ • prepareδϣϒͰΩϟογϡͯ͠, ͦΕΛར༻͢ΔΑ͏ʹ͢Δ
ϫʔΫϑϩʔͷ ༷ࢠ jobs : prepare : runs-on: ubuntu-20.0 4 steps
: - uses: actions/
[email protected]
. 4 - name: Configure AWS Credential s uses: aws-actions/configure-aws-
[email protected]
. 5 with: .. . # path-to-cache ͱ͍͏ϑΝΠϧΛ # Ωϟογϡ͢Δྫ - uses: papix/
[email protected]
. 3 env: .. . with : bucket: ${{ env.cache-bucket } } key: ${{ hashFiles('path-to-cache') } } path: path-to-cach e
ϫʔΫϑϩʔͷ ༷ࢠ jobs : prepare : ... prepareͷॲཧ .. .
test : needs: prepare # needs Ͱ prepare ʹґଘ͢Δ͜ͱΛఆٛ strategy : fail-fast: fals e matrix : id: ["01", "02", "03" ] steps : ... ςετͷॲཧ ...
actions/cache • ΩϟογϡपΓެࣜͷactions/cache͕͋Δ • ͦͦ͜͜ͷසͰΩϟογϡͷऔಘʹࣦഊ͢Δ͜ͱ͕͋ͬͨ • 16ׂ͍ͯ͠Δͱ, ݁ߏͳ֬Ͱऔಘʹࣦഊ͢Δ • ߋʹ,
ň16ׂͨ͠͏ͪͷࣦഊͨ͠1ͭʼnΛ࣮ߦ͢ΔͷෆՄೳ • 16ׂશͯ࠶࣮ߦ͠ͳ͚ΕͳΒͳ͍...
papix/action-cache-s3 • https://github.com/papix/action-cache-s3 • ͦ͜Ͱ, S3Λར༻ͨ͠ΩϟογϡͷΈΛ࡞ͬͨ • ͜ΕͰ, ΩϟογϡΛऔಘग़དྷͣʹࣦഊ͢Δྫ͍ͩͿݮͬͨ
͜͏ͯ͠... • ϒϩάͷςετpush͔ͯ͠Β7ʙ10Ͱऴྃ͢ΔΑ͏ʹͳΓ·ͨ͠ • ͔͠, GitHub Actionsͷδϣϒεέʔϧ͢ΔͷͰ, ෳͷpush͕ ͋ͬͯৗʹಉ࣌ʹͬͯ͘ΕΔ! •
΄΅ϝϯςφϯεϑϦʔͰ, ։ൃମݧ͕େ෯ʹ্!!! • Jenkins࣌ͱൺΔͱ, ࢼࢉͰίετ2/3ʹͳΓ·ͨ͠ • ※ ແྉΛߟྀ͠ͳ͍߹
σϝϦοτ • ϫʔΫϑϩʔactionͷσόοά͕͍͠ • JenkinsͷΑ͏ʹ, ࣮ࡍʹαʔόʔʹೖͬͯڍಈΛݟΔ... ͱ͍͏ͷ͕ ͍͠ • σόοάϩΪϯάΛݩʹ,
ϩά͔Βௐࠪ͢Δඞཁ͕͋Δ • tmuxͷηογϣϯΛੜ͢tmateͱaction-tmateΛͬͯ SSHଓ͢Δ͜ͱՄೳ͕ͩ...
GitHub Actions ͓͠ΖςΫ
Linter/Formatter + reviewdog • reviewdog • https://github.com/reviewdog/reviewdog • GitHubͳͲͷίʔυʹίϝϯτΛ͢͜ͱ͕Ͱ͖Δ •
Linterͷ݁ՌΛ͢ͱ, ܯࠂΛग़ͯ͘͠ΕΔ • ྫ rubocop: https://github.com/reviewdog/action-rubocop • work f l ow commandͰΞϊςʔγϣϯΛ͚Δํ๏͋Γ·͢
Perl::Critic + reviewdog • Perl::Critic • PerlͷߏจΛղੳ͠, ฆΒΘ͍͠ߏจΛࢦఠͯ͘͠ΕΔπʔϧ • Perl::CriticʹରԠͨ͠reviewdogͷactionଘࡏ͠ͳ͍͕...
• Perl::Criticͷग़ྗΛreviewdogʹରԠͨ͠ͷʹมߋ͢ΕOK
Perl::Critic + reviewdog • ৄ͘͠... • ňreviewdog x perlcritic x
Jenkins Ͱ࠷ߴͷ GitHub ϨϏϡʔϥΠ ϑʼn • https://tech.mirrativ.stream/entry/reviewdog-perlcritic-jenkins-for-github-reviewing
GitHub ActionsͰ Perl::CriticΛ͏ name: criti c on : pull_request :
critic : runs-on: ubuntu-lates t steps : - uses: actions/
[email protected]
. 4 - name: Setup reviewdo g uses: reviewdog/
[email protected]
. 2 - name: Criticiz e run: | perlcritic --profile .perlcriticrc --verbose '%f:%l:%c:**%m**, near <code>%r</code>.<br>(Ref: [%p] (https://metacpan.org/pod/Perl::Critic::Policy::%p))\n' lib t | reviewdog -efm=%f:%l:%c:%m -name=perlcritic -reporter=github-pr-review
Perl::Critic + reviewdog
misspell + reviewdog • misspell: https://github.com/client9/misspell • GoͰॻ͔Εͨ, ϛεεϖϧΛൃݟͯ͘͠ΕΔπʔϧ •
ίʔυதͷtypoΛڭ͑ͯ͘ΕΔ • reviewdog/action-misspell • Pull Requestʹࣗಈతʹίϝϯτͯ͘͠ΕΔ
GitHub ActionsͰ misspellΛ͏ name: misspel l on : pull_request :
jobs : misspell : runs-on: ubuntu-lates t steps : - uses: actions/
[email protected]
. 4 - name: misspel l uses: reviewdog/
[email protected]
. 0 with : reporter: 'github-pr-review '
reviewdog/action-misspell
ϥϕϧͷνΣοΫ • Pull RequestʹϥϕϧΛ͚ͭΔӡ༻ϑϩʔ • ྫ: ϦϦʔεʹΑͬͯϢʔβʔͷӨڹ͕͋Δ࣌ňӨڹ͋Γʼn, ͦ͏Ͱͳ͍࣌ňӨڹͳ͠ʼnͷϥϕϧΛ͚ͭΔ •
GitHub ActionsͰ, ϥϕϧͷ͚ͭΕʹܯࠂ͢Δ͜ͱՄೳ • https://github.com/danielchabr/pr-labels-checker
ϥϕϧͷ ࣗಈνΣοΫ name: label-chec k on : pull_request : jobs
: check-labels : runs-on: ubuntu-lates t steps : - uses: danielchabr/pr-labels-checker@v2. 2 with : hasSome: Өڹ͋Γ,Өڹͳ͠
·ͱΊ
·ͱΊ • ͯͳͰͷGitHub Actionsͷ׆༻ࣄྫΛհ͠·ͨ͠ • Jenkins͔ΒGitHub ActionsʹҠߦ͢Δ͜ͱͰ, ϝϯςφϯεϑϦʔ ͳCIڥΛैདྷΑΓίετͰ࣮ݱग़དྷΔΑ͏ʹͳΓ·ͨ͠ •
GitHub ActionsͷศརͳactionΛ׆༻͢Δ͜ͱͰ, ༷ʑͳޮԽΛ ࣮ݱ͢Δ͜ͱՄೳͰ͢
We are hiring! ͯͳͰ, CI/CD, ͦͯࣗ͠ಈԽʹڵຯͷ͋Δ ΤϯδχΞΛืू͍ͯ͠·͢!!!! https://hatenacorp.jp/recruit/engineer