-
Notifications
You must be signed in to change notification settings - Fork 1
252 lines (211 loc) Β· 7.34 KB
/
pipeline.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
name: "Pipeline"
on:
workflow_dispatch:
push:
paths-ignore:
- ".github/**"
- "docs/**"
- "cypress/**"
- "**/*.test.ts"
- "README.md"
- "License.md"
- ".gitignore"
- ".prettierignore"
- ".prettierrc.json"
- "cypress.config.ts"
branches:
- main
pull_request:
paths-ignore:
- ".github/**"
- "docs/**"
- "README.md"
- "License.md"
- ".gitignore"
- ".prettierignore"
- ".prettierrc.json"
- "cypress.config.ts"
branches:
- main
# https://stackoverflow.com/questions/74117321/if-condition-in-concurrency-in-gha
# A PR will have workflows in the same group, different PRs will have workflows in different groups, and each main workflow will have different group IDs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
code_scan:
runs-on: ubuntu-latest
steps:
- name: π Setup repo
uses: actions/checkout@v3
- name: Prettier Check
run: |
npm i [email protected]
npx prettier --check .
app_preview_dev:
if: ${{ contains(fromJSON('["pull_request"]'), github.event_name)}}
runs-on: ubuntu-latest
needs: [ code_scan ]
steps:
- name: π Setup repo
uses: actions/checkout@v3
- name: π Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: π Setup Expo
uses: expo/expo-github-action@v7
with:
expo-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: π¦ Install dependencies
run: npm ci && npx expo install expo-updates
- name: π Publish App preview
run: USERGAMESTATISTICSBFFURL=${{ secrets.DEV_USERGAMESTATISTICSBFFURL }} USERACTIVEGAMESBFFURL=${{ secrets.DEV_USERACTIVEGAMESBFFURL }} DOMAIN=${{ secrets.DEV_DOMAIN }} CLIENT_ID=${{ secrets.DEV_CLIENT_ID }} AUDIENCE=${{ secrets.DEV_AUDIENCE }} SCOPE=${{ secrets.DEV_SCOPE }} expo publish --release-channel=pr-${{ github.event.number }} --non-interactive
- name: Publish Website Preview
run: echo "previewUrl=$(npx vercel --yes --name sudokuru-dev --token ${{secrets.VERCEL_TOKEN}})" >> $GITHUB_ENV
- name: Post comment with preview link
uses: KeisukeYamashita/create-comment@v1
with:
check-only-first-line: true
comment: |
Preview App for PR:
https://expo.dev/@sudokuru/sudokuru?serviceType=classic&distribution=expo-go&release-channel=pr-${{ github.event.number }}
Preview Website for PR:
${{ env.previewUrl }}
website_test_dev:
runs-on: ubuntu-latest
needs: [ code_scan ]
steps:
- name: π Setup repo
uses: actions/checkout@v3
- name: π Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: install dependencies
run: npm i
- name: Jest run
run: npm run test:unit
- name: Test Reporter
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: JEST Tests
path: junit.xml
reporter: jest-junit
- name: Cypress run
uses: cypress-io/github-action@v5
with:
start: 'npm run web:dev'
command: 'npm run test:cypress'
wait-on: 'http://localhost:19000/'
wait-on-timeout: 120
- name: Coveralls
uses: coverallsapp/github-action@v2
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- run: npx nyc report --reporter=text > coverage-final.txt
working-directory: ./coverage
- uses: fingerprintjs/action-coverage-report-md@v1
id: coverage
with:
textReportPath: './coverage/coverage-final.txt'
srcBasePath: ''
- run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Code Coverage" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.coverage.outputs.markdownReport }}" >> $GITHUB_STEP_SUMMARY
- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ contains(fromJSON('["pull_request"]'), github.event_name)}}
with:
message: ${{ steps.coverage.outputs.markdownReport }}
app_build_android:
runs-on: ubuntu-latest
needs: [ code_scan ]
steps:
- name: π Setup repo
uses: actions/checkout@v3
- name: π Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: π Setup Expo and EAS
uses: expo/expo-github-action@v7
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: π¦ Install dependencies
run: npm ci
- name: π Build app
run: eas build --non-interactive --platform android --local
env:
EAS_LOCAL_BUILD_ARTIFACTS_DIR: Build
- name: Upload APK Artifact
uses: actions/upload-artifact@v3
with:
name: Android APK
path: Build/*.apk
deploy_app_dev:
name: Deploy Dev app to Itch.io
needs: [ app_build_android, website_test_dev ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Download APK Artifact
uses: actions/download-artifact@v3
with:
name: Android APK
- name: Install Butler
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V
- name: Update Itch.io Android Alpha App
run: ./butler push . ${{secrets.ITCH_USERNAME}}/${{secrets.ITCH_GAME_ID}}:alpha-android
env:
BUTLER_API_KEY: ${{secrets.BUTLER_API_KEY}}
deploy_app_prod:
name: Deploy Prod app to Itch.io
needs: [ deploy_website_dev, deploy_app_dev ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Download APK Artifact
uses: actions/download-artifact@v3
with:
name: Android APK
- name: Install Butler
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V
- name: Update Itch.io Android Prod App
run: ./butler push . ${{secrets.ITCH_USERNAME}}/${{secrets.ITCH_GAME_ID}}:stable-android
env:
BUTLER_API_KEY: ${{secrets.BUTLER_API_KEY}}
deploy_website_dev:
name: Deploy Dev Website
needs: [ app_build_android, website_test_dev ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- run: npm ci
- run: npx vercel --yes --prod --name sudokuru-dev --token ${{secrets.VERCEL_TOKEN}}
deploy_website_prod:
name: Deploy Prod Website
needs: [ deploy_website_dev, deploy_app_dev ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- run: npm ci
- run: npx vercel --yes --prod --name sudokuru --token ${{secrets.VERCEL_TOKEN}}