Skip to content

Commit 7d0d2c4

Browse files
committed
Verify if dist directory is consistent with the changes or not in CI
1 parent 26d78cc commit 7d0d2c4

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/check-dist.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Originally taken from: https://github.com/actions/typescript-action/blob/cebb7a99fe3172ff475be1ca488335e710c873c3/.github/workflows/check-dist.yml
2+
#
3+
# In TypeScript actions, `dist/` is a special directory. When you reference
4+
# an action with the `uses:` property, `dist/index.js` is the code that will be
5+
# run. For this project, the `dist/index.js` file is transpiled from other
6+
# source files. This workflow ensures the `dist/` directory contains the
7+
# expected transpiled code.
8+
#
9+
# If this workflow is run from a feature branch, it will act as an additional CI
10+
# check and fail if the checked-in `dist/` directory does not match what is
11+
# expected from the build.
12+
name: Check Transpiled JavaScript
13+
14+
on:
15+
pull_request:
16+
branches:
17+
- main
18+
push:
19+
branches:
20+
- main
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
check-dist:
27+
name: Check dist/
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout
32+
id: checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Node.js
36+
id: setup-node
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version-file: .node-version
40+
cache: npm
41+
42+
- name: Install Dependencies
43+
id: install
44+
run: npm ci
45+
46+
- name: Build dist/ Directory
47+
id: build
48+
run: npm run package
49+
50+
# This will fail the workflow if the `dist/` directory is different than
51+
# expected.
52+
- name: Compare Directories
53+
id: diff
54+
run: |
55+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
56+
echo "Detected uncommitted changes after build. See status below:"
57+
git diff --ignore-space-at-eol --text dist/
58+
exit 1
59+
fi
60+
61+
# If `dist/` was different than expected, upload the expected version as a
62+
# workflow artifact.
63+
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
64+
name: Upload Artifact
65+
id: upload
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: dist
69+
path: dist/

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.12.2

0 commit comments

Comments
 (0)