Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
9
3.8k
カンファレンスの「アレ」Webでなんとかしませんか? / Conference “thing” Why don't you do something about it on the Web?
dero1to
2
160
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
2
340
CSC509 Lecture 13
javiergs
PRO
0
150
talk-with-local-llm-with-web-streams-api
kbaba1001
0
130
テストコード文化を0から作り、変化し続けた組織
kazatohiei
1
110
PaaSとSaaSの境目で信頼性と開発速度を両立する 〜TROCCO®︎のこれまでとこれから〜
gtnao
6
6.1k
Reckoner における Datadog Browser Test の活用事例 / Datadog Browser Test at Reckoner
nomadblacky
0
180
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
10
4.1k
Jakarta EE meets AI
ivargrimstad
0
1k
Criando Commits Incríveis no Git
marcelgsantos
1
120
初めてDefinitelyTypedにPRを出した話
syumai
0
480
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
480
Making Projects Easy
brettharned
116
5.9k
A Tale of Four Properties
chriscoyier
157
23k
Thoughts on Productivity
jonyablonski
67
4.3k
Code Review Best Practice
trishagee
64
17k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
KATA
mclloyd
29
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
17k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
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Ͱఏڙ͞Εͳ͍ڥΛ͍͍ͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠