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
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
120
GitHub Actionsのカスタムアクションを作成してMarketplaceで公開した話
yorifuji
0
52
Flutter開発とGitHub Actions
yorifuji
0
130
Other Decks in Programming
See All in Programming
Node.js v22 で変わること
yosuke_furukawa
PRO
11
3.9k
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
380
What We Can Learn From OSS
inouehi
0
430
Try creating your own orderedmap
kazamori
1
180
Micro Frontends for Java Microservices - Utah JUG 2024
mraible
PRO
1
110
Ruby Pattern Matching
bkuhlmann
0
930
Build Apps for iOS, Android & Desktop in 100% Kotlin With Compose Multiplatform (mDevCamp 2024)
zsmb
0
430
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
280
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
1k
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
170
新宿ダンジョンを可視化してみた
satoshi7190
3
390
Let's learn code review
riofujimon
2
570
Featured
See All Featured
Building Adaptive Systems
keathley
32
1.9k
Product Roadmaps are Hard
iamctodd
45
9.7k
Facilitating Awesome Meetings
lara
43
5.6k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
13
8.3k
Statistics for Hackers
jakevdp
790
220k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
26
2.3k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
The Straight Up "How To Draw Better" Workshop
denniskardys
228
130k
Git: the NoSQL Database
bkeepers
PRO
423
63k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
Build your cross-platform service in a week with App Engine
jlugia
226
17k
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Ͱఏڙ͞Εͳ͍ڥΛ͍͍ͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠