Skip to content

Commit 8d06e6c

Browse files
Create check-dist.yml (#227)
* Create check-dist.yml * steps.if still needs ${{ }} when the expr has operators * single quotes? * npm install * mess with index.js * add if failure() * Copy the correct version back in from the artifact * Update .github/workflows/check-dist.yml Co-authored-by: Konrad Pabjan <konradpabjan@github.com> * formatting & language * npm ci Co-authored-by: Konrad Pabjan <konradpabjan@github.com>
1 parent 27121b0 commit 8d06e6c

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

.github/workflows/check-dist.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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
5+
# from other source files.
6+
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
7+
name: Check dist/
8+
9+
on:
10+
push:
11+
branches:
12+
- main
13+
paths-ignore:
14+
- '**.md'
15+
pull_request:
16+
paths-ignore:
17+
- '**.md'
18+
workflow_dispatch:
19+
20+
jobs:
21+
check-dist:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- name: Set Node.js 12.x
28+
uses: actions/setup-node@v1
29+
with:
30+
node-version: 12.x
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Move the committed index.js file
36+
run: mv dist/index.js /tmp
37+
38+
- name: Rebuild the index.js file
39+
run: npm run release
40+
41+
- name: Compare the expected and actual index.js files
42+
run: git diff --ignore-all-space dist/index.js /tmp/index.js
43+
id: diff
44+
45+
# If index.js was different than expected, upload the expected version as an artifact
46+
- uses: actions/upload-artifact@v2
47+
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
48+
with:
49+
name: index.js
50+
path: dist/index.js

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
with:
3131
node-version: 12.x
3232

33-
- name: npm install
34-
run: npm install
33+
- name: Install dependencies
34+
run: npm ci
3535

3636
- name: Compile
3737
run: npm run build

0 commit comments

Comments
 (0)