generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (198 loc) · 6.11 KB
/
node.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
name: Node.js CI/CD
on:
push:
branches:
- main
pull_request:
permissions:
actions: read
jobs:
lint:
name: Lint Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Enable Corepack
run: corepack enable
- name: Use Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@v4.1.0
with:
node-version: ${{ vars.NODE_VERSION }}
cache: npm
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: ESLint
run: npm run lint:eslint
- name: Prettier
run: npm run lint:prettier
unit-test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Enable Corepack
run: corepack enable
- name: Use Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@v4.1.0
with:
node-version: ${{ vars.NODE_VERSION }}
cache: npm
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: Unit Test
run: npm test -- --coverage
- name: Report Code Coverage to codecov
uses: codecov/codecov-action@v5.1.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Enable Corepack
run: corepack enable
- name: Use Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@v4.1.0
with:
node-version: ${{ vars.NODE_VERSION }}
cache: npm
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Upload Action Assets
uses: actions/upload-artifact@v4.5.0
with:
name: dist
path: dist
include-hidden-files: true
integration-test:
name: Integration Test
needs: [build]
environment: Develop # To use debug log (ACTIONS_STEP_DEBUG=true)
strategy:
matrix:
os:
- ubuntu-24.04
- ubuntu-22.04
- ubuntu-20.04
- macos-15
- macos-14
- macos-13
- windows-2025
- windows-2022
- windows-2019
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4.2.2
with:
sparse-checkout: action.yml
sparse-checkout-cone-mode: false
- name: Download Action Assets
uses: actions/download-artifact@v4.1.8
with:
name: dist
path: dist
- name: Execute GitHub Action
id: act
uses: ./
with:
contents: |
foo
bar
baz
weights: |
10
10
10
- name: Echo Action outputs
env:
STEPS_CONTEXT: ${{ toJson(steps.act.outputs) }}
run: echo $STEPS_CONTEXT
diff:
name: Compare Build Assets
if: github.event_name == 'pull_request'
needs: [build]
permissions:
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
with:
ref: ${{ vars.RELEASE_BRANCH }}
sparse-checkout: dist
- name: Enable Corepack
run: corepack enable
- name: Use Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@v4.1.0
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Download Current Action Assets
uses: actions/download-artifact@v4.1.8
with:
name: dist
path: current
- name: Setup js-beautify to compare minified js files
run: |
npm install --global js-beautify
git config --local diff.minjs.textconv js-beautify
echo "index.js diff=minjs" > .gitattributes
- name: Compare
id: compare
continue-on-error: true
run: git diff --no-index --exit-code ./dist/ ./current/
- name: Report Summary
if: steps.compare.outcome == 'failure'
continue-on-error: true
run: |
echo '# Compare ${{ github.sha }} to ${{ github.base_ref }}' >> $GITHUB_STEP_SUMMARY
echo '```diff' >> $GITHUB_STEP_SUMMARY
git diff --no-index ./dist/ ./current/ >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Report diff
if: steps.compare.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const message = 'There is a difference in the build results.'
core.warning(message)
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${message} [Show More](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`
})
deploy:
name: Deploy to Release branch
if: github.event_name == 'push'
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Release Branch
uses: actions/checkout@v4.2.2
with:
ref: ${{ vars.RELEASE_BRANCH }}
- name: Restore Documents from ${{ github.ref_name }}
run: |
git fetch --no-tags --depth=1 origin +${{ github.ref }}:refs/remotes/origin/${{ github.ref_name }}
git restore --source=origin/${{ github.ref_name }} -- *.md
git restore --source=origin/${{ github.ref_name }} -- LICENSE
git restore --source=origin/${{ github.ref_name }} -- action.yml
git restore --source=origin/${{ github.ref_name }} -- .github/workflows/release.yml
- name: Download Build Assets
uses: actions/download-artifact@v4.1.8
with:
name: dist
path: dist
- name: Commit and Push
continue-on-error: true
run: |
git config user.name ${{ vars.GH_ACTIONS_COMMIT_NAME }}
git config user.email ${{ vars.GH_ACTIONS_COMMIT_EMAIL }}
git add .
git commit -m "build: deploy via ${{ github.sha }}"
git push