Update workflows

This commit is contained in:
Nick Alteen
2023-09-14 10:37:52 -04:00
parent cfa5739bef
commit 8a93a79723
5 changed files with 95 additions and 45 deletions

View File

@@ -1,8 +1,11 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
# In JavaScript actions, `dist/index.js` is a special file. When you reference
# an action with `uses:`, `dist/index.js` is the code that will be run. For this
# project, the `dist/index.js` file is generated from other source files through
# the build process. We need to make sure that the checked-in `dist/index.js`
# file matches what is expected from the build.
#
# This workflow will fail if the checked-in `dist/index.js` file does not match
# what is expected from the build.
name: Check dist/
on:
@@ -18,32 +21,43 @@ on:
jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
steps:
- uses: actions/checkout@v3
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Set Node.js 16.x
uses: actions/setup-node@v3.6.0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20
cache: npm
- name: Install dependencies
- name: Install Dependencies
id: install
run: npm ci
- name: Rebuild the dist/ directory
run: npm run prepare
- name: Build dist/ Directory
id: build
run: npm run bundle
- name: Compare the expected and actual dist/ directories
- name: Compare Expected and Actual Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
id: diff
# If index.js was different than expected, upload the expected version as an artifact
# If index.js was different than expected, upload the expected version as
# a workflow artifact.
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with: