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