Skip to content

Commit ee1b2d9

Browse files
committed
Update check-dist.yml workflow with template.
1 parent 6cf8f98 commit ee1b2d9

File tree

2 files changed

+42
-20
lines changed

2 files changed

+42
-20
lines changed

.github/workflows/check-dist.yml

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
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
711

812
on:
913
push:
@@ -16,40 +20,57 @@ on:
1620
paths-ignore:
1721
- '**.md'
1822
workflow_dispatch:
23+
1924
permissions:
2025
contents: read
2126

2227
jobs:
2328
check-dist:
29+
name: Check dist/
2430
runs-on: ubuntu-latest
2531

2632
steps:
27-
- uses: actions/checkout@v4
33+
- name: Checkout
34+
id: checkout
35+
uses: actions/checkout@v4
2836

29-
- name: Set Node.js 20.x
37+
- name: Setup Node.js
38+
id: setup-node
3039
uses: actions/setup-node@v4
3140
with:
32-
node-version: 20.x
41+
node-version-file: .node-version
3342
cache: npm
3443

35-
- name: Install dependencies
44+
- name: Install Dependencies
45+
id: install
3646
run: npm ci
3747

38-
- name: Rebuild the dist/ directory
39-
run: npm run build
48+
- name: Build dist/ Directory
49+
id: build
50+
run: npm run bundle
4051

41-
- name: Compare the expected and actual dist/ directories
52+
# This will fail the workflow if the `dist/` directory is different than
53+
# expected.
54+
- name: Compare Directories
55+
id: diff
4256
run: |
43-
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
44-
echo "Detected uncommitted changes after build. See status below:"
45-
git diff
57+
if [ ! -d dist/ ]; then
58+
echo "Expected dist/ directory does not exist. See status below:"
59+
ls -la ./
60+
exit 1
61+
fi
62+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
63+
echo "Detected uncommitted changes after build. See status below:"
64+
git diff --ignore-space-at-eol --text dist/
4665
exit 1
4766
fi
48-
id: diff
4967
50-
# If index.js was different than expected, upload the expected version as an artifact
51-
- uses: actions/upload-artifact@v4
52-
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
68+
# If `dist/` was different than expected, upload the expected version as a
69+
# workflow artifact.
70+
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
71+
name: Upload Artifact
72+
id: upload
73+
uses: actions/upload-artifact@v4
5374
with:
5475
name: dist
5576
path: dist/

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.9.0

0 commit comments

Comments
 (0)