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
iOSアプリ開発でGitHub Actionsのself-hosted runnerを使う
Search
yorifuji
June 20, 2023
Programming
1
1.3k
iOSアプリ開発でGitHub Actionsのself-hosted runnerを使う
potatotips #82
yorifuji
June 20, 2023
Tweet
Share
More Decks by yorifuji
See All by yorifuji
GitHub Actionsのカスタムアクションを公開する
yorifuji
0
200
GitHub Actionsのカスタムアクションを作成してMarketplaceで公開した話
yorifuji
0
100
Flutter開発とGitHub Actions
yorifuji
0
180
Other Decks in Programming
See All in Programming
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
120
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
570
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
140
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
110
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
100
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
270
Featured
See All Featured
How GitHub (no longer) Works
holman
310
140k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
700
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Documentation Writing (for coders)
carmenintech
65
4.4k
Facilitating Awesome Meetings
lara
50
6.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Transcript
iOSΞϓϦ։ൃͰGitHub Actionsͷ self-hosted runnerΛ͏ YORIFUJI MITSUNORI potatotips #82
ࣗݾհ • ໊લ • YORIFUJI MITSUNORI • Twitter/GitHub/Zenn @yorifuji •
ܦྺ • SIerͰγεςϜΤϯδχΞ -> ࡢ4݄͔ΒFOLIOͰiOSΤϯδχΞʢ2ʣ • Swift, FlutterΞϓϦ։ൃ • ࠷ۙڵຯͷ͋Δ͜ͱ • CI/CD
About GitHub Actions • GitHubʹ౷߹͞ΕͨCIػೳɺGitHubΛར༻͍ͯ͠Ε͙ʹར༻Ͱ͖Δ • ଞࣾͷCI/CDαʔϏεͷαΠϯΞοϓGitHub࿈ܞͳͲ͕ෆཁ • GitHub্Ͱൃੜ͢ΔΠϕϯτΛτϦΨʔʹϫʔΫϑϩʔʢδϣϒʣΛ࣮ߦͰ͖Δ •
ϑΝΠϧͷมߋʢίʔυͷϓογϡʣɺϒϥϯνɺTagɺͳͲͷGitͷΠϕϯτ • Issueͷ࡞ɺPRͷApproveɺϦϙδτϦΛforkͨ͠ɺͳͲͷGitHubͷΠϕϯτ
Work fl ow name: sample workflow run-name: Hello GitHub Actions
on: [push] jobs: job1: runs-on: macos-latest steps: - run: uname -a - run: echo Hello, job1 job2: runs-on: ubuntu-latest steps: - run: uname -a - run: echo Hello, job2 δϣϒͷ༰Λهड़ͨ͠YAMLϑΝΠϧ ΛϦϙδτϦͷ .github/work fl ows ϑΥϧμʹՃ͢Δ
GitHub-hosted runner • GitHub͕ఏڙ͢ΔϫʔΫϑϩʔͷ࣮ߦڥʢVMʣ • Windows, Linux, macOS • ϫʔΫϑϩʔͰLabelΛͬͯࢦఆ͢Δ
• ͦͷΫϦʔϯͳڥׂ͕ΓͯΒΕΔ • XcodeAndroid SDKͳͲͷදతͳ։ൃπʔϧ͕ΠϯετʔϧࡁΈ runs-on: macos-latest
GitHub-hosted runnerͷߏ • https://github.com/actions/runner-images Ͱެ։͞Ε͍ͯΔ
https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md (2023.6.18࣌)
Example .github/work fl ows/sample.yml
Example .github/work fl ows/sample.yml
ྉۚ • ύϒϦοΫϦϙδτϦͰͷར༻ແྉʂ • ϓϥΠϕʔτϦϙδτϦ • GitHub-hosted runnerͷར༻࣌ؒͱετϨʔδʹରͯ͠՝ۚ • ແྉ͋Γ
GitHub Actions(GitHub-hosted runnerʣͷᙱ͍ͱ͜Ζ • macOSΠϯελϯεͷεϖοΫ • 3-Core Intel mac •
Xcodeͷߋ৽ʹλΠϜϥά͕͋Δ • Xcode14.3.1͕࠷৽ɺXcode15.0(beta)·ͩ͑ͳ͍ʢ6.18࣌ʣ • PR͕Approve͞Ε͍ͯΔͷͰ͏͙͑ͦ͏ʢʁʣ • https://github.com/actions/runner-images/pull/7707 • ༻ূ໌ॻɺProvisioning Pro fi leͳͲͷѻ͍ʹҰख͔͔ؒΔ • GitHub ActionsʹϑΝΠϧΞοϓϩʔμʔఏڙ͞Ε͍ͯͳ͍ • ϓϥΠϕʔτϦϙδτϦͰͷ՝ۚ
About self-hosted runner • self-hosted runner=ॴ༗͍ͯ͠ΔϚγϯͰϫʔΫϑϩʔ࣮ߦ͢ΔγεςϜɾϗετ • ϩʔΧϧϚγϯͰϫʔΫϑϩʔΛ࣮ߦ͢ΔͨΊͷrunnerʢagentʣ͕ఏڙ͞Ε͍ͯΔ • ಛ
• ҙͷϚγϯΛϫʔΫϑϩʔͷ࣮ߦʹར༻Ͱ͖Δ • ։ൃπʔϧඞཁʹԠͯࣗ͡༝ʹΠϯετʔϧͰ͖Δ • ϓϥΠϕʔτϦϙδτϦͰͷϫʔΫϑϩʔͷ࣮ߦ࣌ؒʹର͢Δྉ͕ۚൃੜ͠ͳ͍ • ੍ • Ϛγϯͷཧɾӡ༻ίετʢOSͷΞοϓσʔτιϑτΣΞͳͲʣࣗͪ • VMͷػೳఏڙ͞Ε͍ͯͳ͍ͷͰΰϛ͕ͬͨΓ͢Δ • GitHub-hosted runnerͱself-hosted runnerͷ༷ࠩҟͷରԠ -
Setup self-hostd runner name: self hosted sample workflow run-name: Hello
self-hosted runner on: [push] jobs: job1: runs-on: self-hosted steps: - run: uname -a - run: echo Hello, job1 • CIαʔόʔ༻ͷϚγϯΛ༻ҙ͢Δ • iOS։ൃͳΒmacOS͕ඞཁ • ։ൃπʔϧΛΠϯετʔϧ • XcodeͳͲ • self-hosted runnerΛΠϯετʔϧ • ϫʔΫϑϩʔͰself-hosted runnerΛࢦఆ
CIαʔόͷϚγϯΛ༻ҙ͢Δ🤔
💸
GitHub-hostedͱself-hostedͷϫʔΫϑϩʔڞ௨Խ • GitHub-hostedͱself-hostedͷϫʔΫϑϩʔͷେ෦ڞ௨ • VariablesΛ࣮ͬͯߦڥΛΓସ͑Δ • ϦϙδτϦʹରͯ͠ϫʔΫϑϩʔ͔ΒࢀরͰ͖ΔมΛઃఆͰ͖Δ • ύϒϦοΫϦϙδτϦͳΒGitHub-hostedΛɺϓϥΠϕʔτself-hostedΛ͏
XcodeόʔδϣϯͷΓସ͑ • XcodeͷόʔδϣϯͷΓସ͑ϫʔΫϑϩʔͰ env: Λఆٛͯ͠DEVELOPER_DIRڥม Λઃఆ͢Δ • export DEVELOPER_DIR=/Applications/Xcode... ͱಉ͡ޮՌΛൃش
• VariablesʹόʔδϣϯΛఆٛ͢ΔͱΓସ͕͑؆୯
iOSϏϧυͷূ໌ॻཧ • ipaͷϏϧυ༻ূ໌ॻʢApple DistributionʣͱProvisioning Pro fi le͕ඞཁ • ূ໌ॻཧύλʔϯ •
ϗετϚγϯʹΠϯετʔϧʢKeychainʹొʣ • self-hosted runnerͰͷར༻&ಛఆͷTeamͷॺ໊ͷΈͰ͋ΕબՄೳͳํ๏ • GitHub Actions͕ఏڙ͢ΔSecretsʢKey-Value storeʣΛͬͯϦϙδτϦʹొ • ϑΝΠϧΛbase64Ͱencodeͯ͠ొ -> ࣮ߦ࣌ʹdecodeͯ͠ϑΝΠϧʹॻ͖ग़͢ • Cloud signingʢApp Store Connect APIʣ
Cloud signing(App Store Connect API) • Xcode13 Ҏ߱Ͱར༻ՄೳͳɺAppleͷαʔόʔ্Ͱipaʹॺ໊͢Δػೳ • https://developer.apple.com/videos/play/wwdc2021/10204/
• XcodeͰAppleIDΛར༻ɺCIڥʢxcodebuildʣͰApp Store Connect APIͷೝূใ͕ඞཁ • ϝϦοτ • ৴ূ໌ॻʢApple DistributionʣProvisioning Pro fi leͷ࡞ɾஔ͕ෆཁ • App Store Connect APIͷೝূใແظݶͷͨΊߋ৽ͷඞཁ͕ͳ͍ • σϝϦοτ • App Store Connect APIͷೝূใΛAdminݖݶͰ͍ग़͢ඞཁ͕͋Δ
Cloud signingͷར༻खॱ • ϓϩδΣΫτϑΝΠϧͷAutomatically manage signing͕༗ޮͰ͋Δ͜ͱ
Cloud signingͷར༻खॱ • App Store ConnectͰAPIΩʔΛ͍ग़͢ • Issue ID •
Key ID • .p8ϑΝΠϧ
ExportOptions.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> ... <key>method</key> <string>app-store</string> <key>signingStyle</key> <string>automatic</string> <key>destination</key> <string>export</string> <key>teamID</key> <string>{͝ར༻ͷTeamID}</string> ... </dict> </plist> 9DPEF͔Β"SDIJWFΛ࣮ߦͨ͠ޙʹ0SHBOJ[FSͷ%JTUSJCVUF"QQͰ&YQPSUͯ͠ੜ
xcodebuild with Cloud signing xcodebuild archive CODE_SIGNING_ALLOWED=NO ... xcodebuild -exportArchive
... \ -exportOptionsPlist ./ExportOptions.plist \ -allowProvisioningUpdates \ -authenticationKeyIssuerID $ISSUER_ID \ -authenticationKeyID $KEY_ID \ -authenticationKeyPath `pwd`/private_keys/AuthKey_$KEY_ID.p8 • xcodebuild archiveʹCODE_SIGNING_ALLOWED=NOΛ༩͢Δ͜ͱͰarchiveͰͷॺ໊ΛແޮԽ͢Δ • xcodebuild -exportArchiveʹCloud signingʹඞཁͳύϥϝʔλΛࢦఆ͢Δ
xcodebuild with Cloud signing(for Flutter iOS) flutter build ios --no-codesign
xcodebuild archive CODE_SIGNING_ALLOWED=NO ... xcodebuild -exportArchive ... \ -exportOptionsPlist ./ExportOptions.plist \ -allowProvisioningUpdates \ -authenticationKeyIssuerID $APPLE_API_ISSUER_ID \ -authenticationKeyID $APPLE_API_KEY_ID \ -authenticationKeyPath `pwd`/private_keys/AuthKey_$APPLE_API_KEY_ID.p8 • fl utter build ios --no-codesign Ҏ֎ڞ௨ • fl utter build ipa ʹରԠ͍ͯ͠ͳ͍༷
self-hosted runnerͰͷCacheͷར༻ • ϫʔΫϑϩʔߴԽʢCIΛૣ͘ऴΘΒͤΔʣͷͨΊʹதؒੜ ύοέʔδϚωʔδϟͷґଘؔCacheͷར༻͕ਪ͞Ε͍ͯΔ • CocoaPods, Pub.devͳͲͷϩʔΧϧΩϟογϡͯ͠ॲཧΛεΩοϓ • ඪ४ͷΩϟογϡػೳʢCache
actionʣΛ͏ͱGitHub͕ఏڙ͢Δ ΩϟογϡαʔόΛ֤ϦϙδτϦ࠷େ10GB·Ͱར༻Ͱ͖Δ
self-hosted runnerͰCache͕͍ • GitHub-hosted runner • Cacheͷupload/download͕͍ʢover 1Gbpsʣ • 1GBఔͷΩϟογϡͰ͋Ε10ඵ΄ͲͰల։Ͱ͖Δ
• self-hosted runner • ΊͪΌͪ͘Ό͍ʢ20Mbpsఔʣ • CacheΛΘͳ͍࣌ΑΓ͘ͳΔ😰
self-hosted runnerͰΩϟογϡ͕͍ͷͳ͔ͥ • GitHub ActionsͷΠϯϑϥͷ࣮ଶAzure PipelinesʢͱݴΘΕ͍ͯΔʣ • GitHub-hosted runnerͷϩέʔγϣϯ •
ʮmacOS ΠϝʔδΛ࣮ߦ͢ΔΤʔδΣϯτɺ3 ίΞͷ CPUɺ14 GB ͷ RAMɺ14 GB ͷ SSD σΟ εΫྖҬΛඋ͑ͨ Mac Pro ʹϓϩϏδϣχϯά͞Ε·͢ɻ ͜ΕΒͷΤʔδΣϯτɺAzure DevOps ৫ͷॴʹؔͳ͘ɺৗʹถࠃͰ࣮ߦ͞Ε·͢ɻʯʢAzure PipelineΑΓʣ • GitHubͷΩϟογϡαʔόʢΞϝϦΧʣͱࣗʢຊʣͷself-hostedϚγϯؒͷ௨৴͕͍ͨΊʢͨͿ Μʣ • GitHub-hosted runnerͰͷΩϟογϡ͕രͳͷར༻͍ͯ͠ΔΩϟογϡαʔόʢAzure Blob Storageʣ͕ཧతʹ͍ۙϩέʔγϣϯʹ͋Δ͔Β
ηΩϡϦςΟ • ηΩϡϦςΟେࣄ • https://docs.github.com/ja/actions/security-guides/security-hardening-for- github-actions • self-hosted runnerύϒϦοΫϦϙδτϦͰΘͳ͍ •
https://docs.github.com/ja/actions/hosting-your-own-runners/managing-self- hosted-runners/about-self-hosted-runners#self-hosted-runner-security • ٕज़هࣄͳͲࢀߟʹͳΓ·͢ • https://engineering.mercari.com/blog/entry/20230609-github-actions-guideline/
GitHub-hosted runner vs self-hosted runner • ΄ͱΜͲͷϢʔεέʔεͰGitHub-hosted runner͕ద͍ͯ͠Δ • ඞཁͳ࣌ʹ͙͢ʹ͑ͯೖ͔Β࣮ӡ༻·ͰΧόʔ
• ϗετڥͷӡ༻ɾཧίετ͕͔͔Βͳ͍ • ύϒϦοΫϦϙδτϦແྉ • Self-hosted runnerͷ͍ॴ • GitHub hostedͰఏڙ͞Εͳ͍ڥΛ͍͍ͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠