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.1k
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
160
GitHub Actionsのカスタムアクションを作成してMarketplaceで公開した話
yorifuji
0
80
Flutter開発とGitHub Actions
yorifuji
0
160
Other Decks in Programming
See All in Programming
CSC307 Lecture 13
javiergs
PRO
0
150
開発部に不満を持っていたCSがエンジニアにジョブチェンしてわかった「勝手に諦めない」ことの大切さ
sakuraikotone
28
16k
Exploring the Gradually Lost Technical Skills in the Cloud Native Era
hwchiu
2
3.9k
さきがけから振り返るアーキテクチャ刷新 / Reflecting on the Architectural Renewal from the Vanguard
nrslib
2
770
Harnessing Large Language Models for Training-free Video Anomaly Detection
tereka114
1
1.3k
CSC307 Lecture 12
javiergs
PRO
0
220
Trial
cairolibrary720
1
130
3 Effective Rules for Success with Signals in Angular
manfredsteyer
PRO
0
120
企業向け生成AIアプリの 開発から得られた知見
takaakikakei
0
310
CSC307 Lecture 11
javiergs
PRO
0
240
Android開発者のための Kotlin Multiplatform入門
ntaro
0
190
実用的かつリーズナブルな 「Azure × Gemini × LINE」~キャラクターBot 実装ライブデモ~
tomodo_ysys
1
170
Featured
See All Featured
Design by the Numbers
sachag
277
18k
5 minutes of I Can Smell Your CMS
philhawksworth
200
19k
The Invisible Customer
myddelton
117
13k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
245
1.2M
Being A Developer After 40
akosma
72
580k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
78
15k
Why Our Code Smells
bkeepers
PRO
332
56k
YesSQL, Process and Tooling at Scale
rocio
166
14k
How STYLIGHT went responsive
nonsquared
93
5k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
26
1.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
23
1.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
13
430
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Ͱఏڙ͞Εͳ͍ڥΛ͍͍ͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠