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
210
GitHub Actionsのカスタムアクションを作成してMarketplaceで公開した話
yorifuji
0
110
Flutter開発とGitHub Actions
yorifuji
0
190
Other Decks in Programming
See All in Programming
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
Full stack testing :: basic to basic
up1
1
930
Zoneless Testing
rainerhahnekamp
0
120
Symfony Mapper Component
soyuka
2
730
useSyncExternalStoreを使いまくる
ssssota
6
1k
The rollercoaster of releasing an Android, iOS, and macOS app with Kotlin Multiplatform | droidcon Italy
prof18
0
150
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
240
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
From Translations to Multi Dimension Entities
alexanderschranz
2
130
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
120
return文におけるstd::moveについて
onihusube
1
750
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
How STYLIGHT went responsive
nonsquared
95
5.2k
A designer walks into a library…
pauljervisheath
204
24k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Practical Orchestrator
shlominoach
186
10k
Writing Fast Ruby
sferik
628
61k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
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Ͱఏڙ͞Εͳ͍ڥΛ͍͍ͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠