-
Notifications
You must be signed in to change notification settings - Fork 14
252 lines (247 loc) · 9.04 KB
/
postCommit.yaml
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: post commit CI
on:
push:
paths:
- scripts/**/*.js
- "!scripts/test/*.js"
- "!scripts/generateUnrecognizableFeatures/*.js"
- "!scripts/detectHardcodedOutdatedNPMPackages/*.js"
- "!scripts/autoAssign/*.js"
- src/**/*.js
- src/**/*.css
- src/**/definition.yaml
- src/gadgets/Gadgets-definition-list.yaml
- .github/workflows/postCommit.yaml
- .vscode/json-schemas/gadget-definition.json
- .browserslistrc
- .*.yaml
- package-lock.json
merge_group:
pull_request:
paths:
- scripts/**/*.js
- "!scripts/test/*.js"
- "!scripts/generateUnrecognizableFeatures/*.js"
- "!scripts/detectHardcodedOutdatedNPMPackages/*.js"
- "!scripts/autoAssign/*.js"
- src/**/*.js
- src/**/*.css
- src/**/definition.yaml
- src/gadgets/Gadgets-definition-list.yaml
- .github/workflows/postCommit.yaml
- .vscode/json-schemas/gadget-definition.json
- .browserslistrc
- .*.yaml
- package-lock.json
workflow_dispatch:
inputs:
manuallyLinterTest:
description: 如需手动触发格式检查,请选择上方 Branch 为 master,下方为 true
type: choice
default: "false"
options:
- "true"
- "false"
schedule:
- cron: 0 23 * * * # Every 07:00 CST
concurrency:
group: ${{ github.workflow_ref }}-${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: write
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: write
statuses: write
jobs:
skipCI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
check-latest: true
cache: npm
- name: Generate cache primary key based on nodejs's and npm's version and package-lock.json's hash
id: version
shell: bash
run: echo "hash=node@$(node -v | grep -oP '(?<=^v)\d+')_npm@$(npm -v | grep -oP '^\d+')_package-lock@$(openssl dgst -sha3-512 package-lock.json | grep -oP '[\da-f]{128}')" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT
- uses: actions/cache/restore@v3
name: Try to restore node_modules from cache
id: cache
with:
path: node_modules
key: ${{ steps.version.outputs.hash }}
- name: Install dependencies if no cache for node_modules
run: npm run ci
if: success() && steps.cache.outputs.cache-hit != 'true'
- uses: actions/cache/save@v3
if: success() && steps.cache.outputs.cache-hit != 'true'
name: Save node_modules to cache
with:
path: node_modules
key: ${{ steps.version.outputs.hash }}
- name: If needs to skip, skip now
run: node scripts/skip/index.js
id: skip
outputs:
skip: ${{ steps.skip.outputs.skip }}
postCommit:
runs-on: ubuntu-latest
needs:
- skipCI
if: success() && needs.skipCI.outputs.skip != 'true'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
check-latest: true
cache: npm
- name: Generate cache primary key based on nodejs's and npm's version and package-lock.json's hash
id: version
shell: bash
run: echo "hash=node@$(node -v | grep -oP '(?<=^v)\d+')_npm@$(npm -v | grep -oP '^\d+')_package-lock@$(openssl dgst -sha3-512 package-lock.json | grep -oP '[\da-f]{128}')" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT
- uses: actions/cache/restore@v3
name: Try to restore node_modules from cache
id: cache
with:
path: node_modules
key: ${{ steps.version.outputs.hash }}
- name: Install dependencies if no cache for node_modules
run: npm run ci
if: success() && steps.cache.outputs.cache-hit != 'true'
- uses: actions/cache/save@v3
if: success() && steps.cache.outputs.cache-hit != 'true'
name: Save node_modules to cache
with:
path: node_modules
key: ${{ steps.version.outputs.hash }}
- name: Git config
run: node scripts/postCommit/prepareGit.js
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v2
- name: Auto browserify generator
run: node scripts/browserify/index.js
- name: Auto prefetch
run: node scripts/prefetch/index.js
- name: Gadget-polyfill generator
run: node scripts/generatePolyfill/index.js
- name: Gadgets-definition Generator
run: node scripts/generateGadgetsDefinition/index.js
- name: Conventional Commits scopes generator
run: node scripts/generateConventionalCommitsScopes/index.js
- name: Commits History generator
run: node scripts/ganerateCommitsHistory/index.js
- name: linguist-generated
run: node scripts/postCommit/linguist-generated.js
- name: Show git status & push
id: output
run: node scripts/postCommit/push.js
outputs:
commits: ${{ steps.output.outputs.commits }}
linterTest: ${{ steps.output.outputs.linterTest }}
linter_test:
runs-on: ubuntu-latest
needs:
- skipCI
- postCommit
if: success() && needs.skipCI.outputs.skip != 'true' && (needs.postCommit.outputs.linterTest == 'true' || github.event.inputs.manuallyLinterTest == 'true')
env:
commits: ${{ needs.postCommit.outputs.commits }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
check-latest: true
cache: npm
- name: Generate cache primary key based on nodejs's and npm's version and package-lock.json's hash
id: version
shell: bash
run: echo "hash=node@$(node -v | grep -oP '(?<=^v)\d+')_npm@$(npm -v | grep -oP '^\d+')_package-lock@$(openssl dgst -sha3-512 package-lock.json | grep -oP '[\da-f]{128}')" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT
- uses: actions/cache/restore@v3
name: Try to restore node_modules from cache
id: cache
with:
path: node_modules
key: ${{ steps.version.outputs.hash }}
- name: Install dependencies if no cache for node_modules
run: npm run ci
if: success() && steps.cache.outputs.cache-hit != 'true'
- uses: actions/cache/save@v3
if: success() && steps.cache.outputs.cache-hit != 'true'
name: Save node_modules to cache
with:
path: node_modules
key: ${{ steps.version.outputs.hash }}
- name: Reload the linter cache
uses: actions/cache@v3
with:
path: .cache
key: cache@${{ github.ref }}
- name: Check eslint environment
run: npx eslint --env-info && mkdir -p .cache && echo ---- && ls -lhA .cache
- name: Run eslint
run: npx eslint --exit-on-fatal-error --max-warnings 0 --cache --cache-strategy content --cache-location ".cache/" --ext js ./src
- name: Run stylelint
run: npx stylelint --max-warnings 0 --cache --cache-strategy content --cache-location ".cache/" "src/**/*.css"
- name: Run v8r
run: echo "::group::v8r output" && npx v8r && echo "::endgroup::"
- name: Check .mailmap
run: node scripts/emailmapChecker/index.js
webhook:
runs-on: ubuntu-latest
needs:
- skipCI
- postCommit
- linter_test
if: always() && needs.skipCI.outputs.skip != 'true'
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
check-latest: true
cache: npm
- name: Generate cache primary key based on nodejs's and npm's version and package-lock.json's hash
id: version
shell: bash
run: echo "hash=node@$(node -v | grep -oP '(?<=^v)\d+')_npm@$(npm -v | grep -oP '^\d+')_package-lock@$(openssl dgst -sha3-512 package-lock.json | grep -oP '[\da-f]{128}')" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT
- uses: actions/cache/restore@v3
name: Try to restore node_modules from cache
id: cache
with:
path: node_modules
key: ${{ steps.version.outputs.hash }}
- name: Install dependencies if no cache for node_modules
run: npm run ci
if: success() && steps.cache.outputs.cache-hit != 'true'
- uses: actions/cache/save@v3
if: success() && steps.cache.outputs.cache-hit != 'true'
name: Save node_modules to cache
with:
path: node_modules
key: ${{ steps.version.outputs.hash }}
- name: Fire the webhook of AnnAngela's server
run: node scripts/fireWebhook/index.js
env:
needs: ${{ toJson(needs) }}
ANN_SERVER_SECRET_API_KEY: ${{ secrets.ANN_SERVER_SECRET_API_KEY }}