-
-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (251 loc) · 8.07 KB
/
ci.yml
File metadata and controls
252 lines (251 loc) · 8.07 KB
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
# Continuous Integration
#
# References:
#
# - https://docs.github.com/actions/learn-github-actions/contexts
# - https://docs.github.com/actions/learn-github-actions/expressions
# - https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#pull_request
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#push
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
# - https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#push
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch
# - https://github.com/actions/cache
# - https://github.com/actions/cache/discussions/650
# - https://github.com/actions/checkout
# - https://github.com/actions/setup-node
# - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#yarn2-configuration
# - https://github.com/actions/upload-artifact
# - https://github.com/dprint/check
# - https://github.com/flex-development/grease
# - https://github.com/flex-development/jq-action
# - https://github.com/flex-development/manver-action
# - https://github.com/hmarr/debug-action
# - https://github.com/streetsidesoftware/cspell-action
---
name: ci
on:
pull_request:
push:
branches:
- feat/**
- hotfix/**
- main
workflow_dispatch:
permissions:
contents: read
env:
CACHE_PATH: node_modules
HUSKY: 0
REF: ${{ github.head_ref || github.ref }}
REF_NAME: ${{ github.head_ref || github.ref_name }}
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
preflight:
if: |
github.event_name == 'pull_request' ||
github.event.head_commit.committer.username != 'web-flow'
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-key.outputs.result }}
version: ${{ steps.version.outputs.build }}
steps:
- id: debug
name: Print environment variables and event payload
uses: hmarr/debug-action@v3.0.0
- id: checkout
name: Checkout ${{ env.REF_NAME }}
uses: actions/checkout@v5.0.0
with:
persist-credentials: false
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v6.0.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: dependencies
name: Install dependencies
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: ${{ github.actor != 'dependabot[bot]' }}
run: yarn
- id: cache-key
name: Get cache key
run: echo "result=${{ hashFiles('yarn.lock') }}" >>$GITHUB_OUTPUT
- id: cache
name: Cache dependencies
uses: actions/cache@v4.3.0
with:
key: ${{ steps.cache-key.outputs.result }}
path: ${{ env.CACHE_PATH }}
- id: version
name: Extract version metadata
uses: flex-development/manver-action@1.1.0
commitlint:
needs: preflight
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF_NAME }}
uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v6.0.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v4.3.0
with:
key: ${{ needs.preflight.outputs.cache-key }}
path: ${{ env.CACHE_PATH }}
- id: lint
name: Check commitlint status
if: github.run_number != '1'
run: yarn commitlint --from $SHA~${{ github.event.pull_request.commits || 1 }} --to $SHA
format:
needs: preflight
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF_NAME }}
uses: actions/checkout@v5.0.0
with:
persist-credentials: false
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v6.0.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v4.3.0
with:
key: ${{ needs.preflight.outputs.cache-key }}
path: ${{ env.CACHE_PATH }}
- id: version
name: Get dprint version
uses: flex-development/jq-action@1.0.0
with:
data: package.json
filter: .devDependencies.dprint
- id: check
name: Check formatting
uses: dprint/check@v2.3
with:
args: --config-discovery=false --incremental=false --log-level=info
config-path: .dprint.jsonc
dprint-version: ${{ steps.version.outputs.result }}
lint:
needs: preflight
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF_NAME }}
uses: actions/checkout@v5.0.0
with:
persist-credentials: false
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v6.0.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v4.3.0
with:
key: ${{ needs.preflight.outputs.cache-key }}
path: ${{ env.CACHE_PATH }}
- id: remark
name: Check markdown files
run: yarn remark
- id: lint
name: Check eslint files
run: yarn check:lint
spelling:
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF_NAME }}
uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ env.REF }}
- id: spelling
name: Check spelling
uses: streetsidesoftware/cspell-action@v7.2.0
with:
config: .cspell.json
inline: error
treat_flagged_words_as_errors: true
verbose: true
artifacts:
needs:
- commitlint
- format
- lint
- preflight
- spelling
runs-on: ubuntu-latest
steps:
- id: tarball
name: Get tarball path
run: |
echo "result=${{ format('@{0}-{1}-{2}.tgz', github.repository_owner, github.event.repository.name, needs.preflight.outputs.version) }}" >>$GITHUB_OUTPUT
- id: checkout
name: Checkout ${{ env.REF_NAME }}
uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v6.0.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v4.3.0
with:
key: ${{ needs.preflight.outputs.cache-key }}
path: ${{ env.CACHE_PATH }}
- id: local-binaries
name: Add local binaries to $PATH
run: echo "$GITHUB_WORKSPACE/$CACHE_PATH/.bin" >> $GITHUB_PATH
- id: changelog
name: Changelog preview
env:
TZ: ${{ vars.TZ }}
run: echo "$(grease changelog)" >>$GITHUB_STEP_SUMMARY
- id: pack
name: Pack project
run: yarn pack -o ${{ steps.tarball.outputs.result }}
- id: archive
name: Archive production artifact
uses: actions/upload-artifact@v4.6.2
with:
name: ${{ steps.tarball.outputs.result }}
path: ${{ steps.tarball.outputs.result }}