-
Notifications
You must be signed in to change notification settings - Fork 0
302 lines (262 loc) · 8.52 KB
/
dev.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
name: on branch push
on:
pull_request:
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dafnik/setup-node-pnpm@v3
with:
install-ignore-scripts: true
- name: Style check
run: pnpm format:check
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dafnik/setup-node-pnpm@v3
with:
install-ignore-scripts: true
- name: Lint project
run: pnpm lint:check
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dafnik/setup-node-pnpm@v3
with:
install-ignore-scripts: true
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: pnpm exec commitlint --from HEAD~1 --to HEAD --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: pnpm exec commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
outputs:
# Expose matched filters as job 'packages' output variable
libs: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
dfts-helper:
- 'libs/dfts-helper/**'
- '{package,nx,migrations,tsconfig.base}.json'
- 'pnpm-lock.yaml'
- '.github/**'
dfts-qrcode:
- 'libs/dfts-qrcode/**'
- '{package,nx,migrations,tsconfig.base}.json'
- 'pnpm-lock.yaml'
- '.github/**'
dfx-bootstrap-table:
- 'libs/dfx-bootstrap-table/**'
- '{package,nx,migrations,tsconfig.base}.json'
- 'pnpm-lock.yaml'
- '.github/**'
dfx-helper:
- 'libs/dfx-helper/**'
- '{package,nx,migrations,tsconfig.base}.json'
- 'pnpm-lock.yaml'
- '.github/**'
dfx-qrcode:
- 'libs/dfx-qrcode/**'
- '{package,nx,migrations,tsconfig.base}.json'
- 'pnpm-lock.yaml'
- '.github/**'
dfx-bootstrap-icons:
- 'libs/dfx-bootstrap-icons/**'
- '{package,nx,migrations,tsconfig.base}.json'
- 'pnpm-lock.yaml'
- '.github/**'
test:
name: Test ${{ matrix.lib }}
runs-on: ubuntu-latest
continue-on-error: true
needs: changes
if: ${{ needs.changes.outputs.libs != '[]' && needs.changes.outputs.libs != '' }}
strategy:
matrix:
lib: ${{ fromJSON(needs.changes.outputs.libs) }}
steps:
- uses: actions/checkout@v4
- name: setup node and pnpm
uses: dafnik/setup-node-pnpm@v3
with:
install-ignore-scripts: true
- name: test ${{ matrix.lib }}
run: pnpm exec nx test ${{ matrix.lib }} --configuration=ci --coverageReporters=cobertura --coverageDirectory="coverage/libs/${{ matrix.lib }}"
- name: setup coverage report
uses: ./.github/actions/setup-coverage-report
with:
path: coverage/libs/${{ matrix.lib }}/cobertura-coverage.xml
build-lib:
name: Build ${{ matrix.lib }}
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.libs != '[]' && needs.changes.outputs.libs != '' }}
strategy:
matrix:
lib: ${{ fromJSON(needs.changes.outputs.libs) }}
steps:
- uses: actions/checkout@v4
- name: setup node and pnpm
uses: dafnik/setup-node-pnpm@v3
with:
install-ignore-scripts: true
- name: build ${{ matrix.lib }}
run: pnpm exec nx build ${{ matrix.lib }}
- name: zip ${{ matrix.lib }}
run: |
cd ./dist/libs/
zip -r "${{ matrix.lib }}.zip" ./${{ matrix.lib }}
cd -
- uses: actions/upload-artifact@v4
name: create ${{ matrix.lib }} artifact
with:
name: ${{ matrix.lib }}
path: ./dist/libs/${{ matrix.lib }}.zip
retention-days: 1
deploy-lib:
name: Deploy ${{ matrix.lib }} dev
needs: [build-lib, test, changes]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
strategy:
matrix:
lib: ${{ fromJSON(needs.changes.outputs.libs) }}
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.lib }}
path: ./dist
- name: dist lookup
run: |
cd dist
mv ${{ matrix.lib }}.zip ./${{ matrix.lib }}-dev.zip
ls -la
cd -
- name: copy build to release server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.RELEASES_SSH_HOST }}
username: ${{ secrets.RELEASES_SSH_USER }}
key: ${{ secrets.RELEASES_SSH_PRIVATE_KEY }}
port: ${{ secrets.RELEASES_SSH_PORT }}
source: dist/*
target: /var/www/share/releases/${{ matrix.lib }}
overwrite: true
build-apps:
name: Build ${{ matrix.app }}
runs-on: ubuntu-latest
strategy:
matrix:
app: ['dfx-bootstrap-table-demo', 'dfx-bootstrap-icons-demo', 'dfx-qrcode-demo', 'playground']
steps:
- uses: actions/checkout@v4
- name: setup node and pnpm
uses: dafnik/setup-node-pnpm@v3
with:
install-ignore-scripts: true
- name: build ${{ matrix.app }}
run: pnpm exec nx build ${{ matrix.app }}
- name: zip ${{ matrix.app }}
run: |
cd ./dist/apps/
zip -r "${{ matrix.app }}.zip" ./${{ matrix.app }}
cd -
- uses: actions/upload-artifact@v4
name: create ${{ matrix.app }} artifact
with:
name: ${{ matrix.app }}
path: ./dist/apps/${{ matrix.app }}.zip
retention-days: 1
bundle-apps:
name: Bundle app artifacts into one
needs: [build-apps]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
name: Download table-demo
with:
name: dfx-bootstrap-table-demo
- uses: actions/download-artifact@v4
name: Download icons-demo
with:
name: dfx-bootstrap-icons-demo
- uses: actions/download-artifact@v4
name: Download qrcode-demo
with:
name: dfx-qrcode-demo
- uses: actions/download-artifact@v4
name: Download playground
with:
name: playground
- name: unzip all
run: |
unzip dfx-bootstrap-table-demo.zip
unzip dfx-bootstrap-icons-demo.zip
unzip dfx-qrcode-demo.zip
unzip playground.zip
- name: move files in place
run: |
mkdir dist
mkdir dist/bootstrap-table
mkdir dist/bootstrap-icons
mkdir dist/qrcode
mkdir dist/base64-pdf-converter
mv playground/* dist/
mv dfx-bootstrap-table-demo/* dist/bootstrap-table/
mv dfx-bootstrap-icons-demo/* dist/bootstrap-icons/
mv dfx-qrcode-demo/* dist/qrcode/
- name: dist lookup
run: |
cd dist
ls -la
du -hs
cd -
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist/
retention-days: 1
deploy-apps:
if: github.ref == 'refs/heads/main'
name: Deploy apps
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: bundle-apps
permissions:
actions: read
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4