-
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (52 loc) · 1.75 KB
/
check-dist.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
name: check-dist
on:
pull_request:
branches: [ main ]
paths:
- 'package.json'
- 'package-lock.json'
- 'src/**'
workflow_dispatch:
permissions:
contents: read
jobs:
check-dist:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- name: Get npm cache directory
id: npm-cache-dir
shell: pwsh
run: echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT}
- name: Setup npm cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Install packages
run: npm ci
- name: Rebuild the dist directory
run: npm run check-dist
- name: Compare the expected and actual dist directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "::error::Detected uncommitted changes to dist."
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
- name: Upload generated dist
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
if: failure() && steps.diff.conclusion == 'failure'
with:
name: dist
path: dist/