-
Notifications
You must be signed in to change notification settings - Fork 1
353 lines (339 loc) Β· 13.1 KB
/
ci-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
name: CI/CD
# JavaScript CI and iOS, Android, and Codepush deployment
on:
push:
branches: [develop, master]
pull_request:
branches: [develop, master]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
ENVFILE: ${{ (github.ref == 'refs/heads/master' || github.base_ref == 'refs/heads/master') && '.env.production' || '.env.staging' }}
permissions:
id-token: write
contents: read
jobs:
split-tests:
runs-on: ubuntu-latest
outputs:
test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- id: set-test-chunks
name: Set Chunks
run: echo "::set-output name=test-chunks::$(yarn --silent test --listTests --json | jq -cM '[_nwise(length / 4 | floor)]')"
- id: set-test-chunk-ids
name: Set Chunk IDs
run: echo "::set-output name=test-chunk-ids::$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')"
env:
CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
test:
runs-on: ubuntu-latest
name: test (chunk ${{ matrix.chunk }})
needs:
- split-tests
strategy:
matrix:
chunk: ${{ fromJson(needs.split-tests.outputs['test-chunk-ids']) }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: π Run GraphQL Codegen
run: |
yarn gql:codegen
yarn gql:schema
- name: π§ͺ Test (chunk ${{ matrix.chunk }})
run: echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs yarn test:coverage --ci
env:
CHUNKS: ${{ needs.split-tests.outputs['test-chunks'] }}
- name: Codecov
run: bash <(curl -s https://codecov.io/bash)
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: π Run GraphQL Codegen
run: |
yarn gql:codegen
yarn gql:schema
- name: π¨ ESLint
run: yarn lint
typescript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: π Run GraphQL Codegen
run: |
yarn gql:codegen
yarn gql:schema
- name: β
TypeScript lint
run: yarn lint:ts
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: π
Prettier Check
run: yarn prettier:check
onesky-upload:
runs-on: ubuntu-latest
needs: [test, eslint, typescript, prettier]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_IAM_ONESKY_ROLE_ARN }}
aws-region: us-east-1
- name: Import OneSky Keys
uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: |
/shared/onesky/PUBLIC_KEY = ONESKY_API_KEY,
/shared/onesky/SECRET_KEY = ONESKY_SECRET_KEY
- name: β
πΌ OneSky Upload
run: yarn onesky:upload
ios-codepush:
runs-on: ubuntu-latest
needs: [test, eslint, typescript, prettier]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: π Run GraphQL Codegen
run: |
yarn gql:codegen
yarn gql:schema
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_IAM_ONESKY_ROLE_ARN }}
aws-region: us-east-1
- name: Import OneSky Keys
uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: |
/shared/onesky/PUBLIC_KEY = ONESKY_API_KEY,
/shared/onesky/SECRET_KEY = ONESKY_SECRET_KEY
- name: β
OneSky Download
run: yarn onesky:download
- name: ποΈππ Build and Codepush iOS
env:
APPCENTER_TOKEN: ${{ secrets.APPCENTER_TOKEN }}
# Codepush can't figure out how to parse MARKETING_VERSION https://github.com/microsoft/react-native-code-push/issues/1665 https://stackoverflow.com/a/58769925/665224
run: yarn codepush-ios-staging --token "$APPCENTER_TOKEN" --sourcemap-output sourcemap.ios.js --extra-bundler-option="--sourcemap-sources-root" --extra-bundler-option="./" --description "#${{ github.run_id }} ${{ github.sha }} | ${{ github.event.head_commit.message }}" -t `sed -n '/MARKETING_VERSION/{s/MARKETING_VERSION = //;s/;//;s/^[[:space:]]*//;p;q;}' ./ios/MissionHub.xcodeproj/project.pbxproj`
- name: πΌππΊοΈ Upload iOS sourcemaps to Rollbar
env:
ROLLBAR_POST_SERVER_ITEM_TOKEN: ${{ secrets.ROLLBAR_POST_SERVER_ITEM_TOKEN }}
run: |
curl https://api.rollbar.com/api/1/sourcemap \
-F access_token=$ROLLBAR_POST_SERVER_ITEM_TOKEN \
-F version=${{ github.sha }}.ios \
-F minified_url=http://reactnativehost/main.jsbundle \
android-codepush:
runs-on: ubuntu-latest
needs: [test, eslint, typescript, prettier]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: π Run GraphQL Codegen
run: |
yarn gql:codegen
yarn gql:schema
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_IAM_ONESKY_ROLE_ARN }}
aws-region: us-east-1
- name: Import OneSky Keys
uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: |
/shared/onesky/PUBLIC_KEY = ONESKY_API_KEY,
/shared/onesky/SECRET_KEY = ONESKY_SECRET_KEY
- name: β
OneSky Download
run: yarn onesky:download
- name: ποΈππ€ Build and Codepush Android
env:
APPCENTER_TOKEN: ${{ secrets.APPCENTER_TOKEN }}
run: yarn codepush-android-staging --token "$APPCENTER_TOKEN" --sourcemap-output sourcemap.android.js --extra-bundler-option="--sourcemap-sources-root" --extra-bundler-option="./" --description "#${{ github.run_id }} ${{ github.sha }} | ${{ github.event.head_commit.message }}"
- name: πΌπ€πΊοΈ Upload Android sourcemaps to Rollbar
env:
ROLLBAR_POST_SERVER_ITEM_TOKEN: ${{ secrets.ROLLBAR_POST_SERVER_ITEM_TOKEN }}
run: |
curl https://api.rollbar.com/api/1/sourcemap \
-F access_token=$ROLLBAR_POST_SERVER_ITEM_TOKEN \
-F version=${{ github.sha }}.android \
-F minified_url=http://reactnativehost/main.jsbundle \
ios-deploy:
runs-on: macos-latest
needs: [test, eslint, typescript, prettier]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: π Run GraphQL Codegen
run: |
yarn gql:codegen
yarn gql:schema
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_IAM_ONESKY_ROLE_ARN }}
aws-region: us-east-1
- name: Import OneSky Keys
uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: |
/shared/onesky/PUBLIC_KEY = ONESKY_API_KEY,
/shared/onesky/SECRET_KEY = ONESKY_SECRET_KEY
- name: β
OneSky Download
run: yarn onesky:download
- name: π Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: β Add Commit SHA to ENVFILE
run: echo "COMMIT_SHA=$GITHUB_SHA" >> ./.env.production
- name: π Configure GitHub login
run: echo -e "machine github.com\n login $CI_USER_TOKEN" >> ~/.netrc
env:
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN}}
- name: Bundle Install
working-directory: ios
run: bundle install
- name: Import App Store Connect API Key
env:
APP_STORE_CONNECT_API_JSON_PAYLOAD: ${{ secrets.APP_STORE_CONNECT_API_JSON_PAYLOAD }}
run: echo $APP_STORE_CONNECT_API_JSON_PAYLOAD > ios/fastlane/AppleAppStoreApi.json
- name: Increment Xcode Project Build Number
uses: maierj/[email protected]
with:
lane: ios cru_shared_lane_increment_xcode_project_build_number
subdirectory: ios
- name: ποΈππ Build and push to Testflight
uses: maierj/[email protected]
with:
lane: ios cru_shared_lane_build_and_deploy_for_testflight_release is_running_in_ci:true
subdirectory: ios
env:
MATCH_GIT_BASIC_AUTHORIZATION_PAT: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION_PAT }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
android-deploy:
runs-on: ubuntu-latest
needs: [test, eslint, typescript, prettier]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
with:
# Used for computing the Android versionCode https://github.com/CruGlobal/missionhub-react-native/blob/4c37730c21baeea3a304702b1bbbbce3d11f320d/android/app/build.gradle#L145
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: egordm/gha-yarn-node-cache@v1
- name: π¦ Install Dependencies
run: yarn
- name: π Run GraphQL Codegen
run: |
yarn gql:codegen
yarn gql:schema
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_IAM_ONESKY_ROLE_ARN }}
aws-region: us-east-1
- name: Import OneSky Keys
uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: |
/shared/onesky/PUBLIC_KEY = ONESKY_API_KEY,
/shared/onesky/SECRET_KEY = ONESKY_SECRET_KEY
- name: β
OneSky Download
run: yarn onesky:download
- name: β Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: π Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: β Add Commit SHA to ENVFILE
run: echo "COMMIT_SHA=$GITHUB_SHA" >> ./.env.production
- name: π Decrypt GooglePlayAPI.json
# Using "-md md5" to support old file from previous version of OpenSSL https://www.openssl.org/docs/faq.html#USER3
run: openssl aes-256-cbc -pass "pass:$GOOGLE_PLAY_API_FILE_PASSWORD" -in ./android/fastlane/GooglePlayAPI.enc -out ./android/fastlane/GooglePlayAPI.json -d -a -md md5
env:
GOOGLE_PLAY_API_FILE_PASSWORD: ${{ secrets.GOOGLE_PLAY_API_FILE_PASSWORD }}
- name: ποΈππ€ Build and push to Android Beta
uses: maierj/[email protected]
with:
lane: android beta
subdirectory: android
env:
TRAVIS_BRANCH: ${{ github.ref }}
TRAVIS_TAG: ${{ github.ref }}
TRAVIS_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
TRAVIS_BUILD_NUMBER: ${{ github.run_id }}
GOOGLE_PLAY_UPLOAD_KEY_PASSWORD: ${{ secrets.GOOGLE_PLAY_UPLOAD_KEY_PASSWORD }}
SLACK_URL: ${{ secrets.SLACK_URL }}