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/
0 commit comments