mirror of
https://github.com/actions/add-to-project.git
synced 2025-12-11 04:32:47 +00:00
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
67 lines
2.4 KiB
YAML
67 lines
2.4 KiB
YAML
# `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.
|
|
name: Check dist/
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- '**.md'
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**.md'
|
|
|
|
env:
|
|
# A pipe-separated array of files to ignore when comparing the expected and actual dist/ directories,
|
|
# which are used as a regular expression filter in the `grep` command.
|
|
FILES_TO_IGNORE: 'index.js.map|sourcemap-register.js'
|
|
|
|
jobs:
|
|
check-dist:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set Node.js 20.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20.x
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Rebuild the dist/ directory
|
|
run: |
|
|
npm run build:compile
|
|
npm run build:package
|
|
|
|
- name: Compare the expected and actual dist/ directories
|
|
run: |
|
|
# Get a list of files that are different between the checked-in dist/ directory and the generated dist/ directory,
|
|
# then trim the list to remove any leading or trailing whitespace.
|
|
CHANGED_FILES=$(git diff --ignore-space-at-eol --name-only dist/ | grep -vE "$FILES_TO_IGNORE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
|
if [ -n "$CHANGED_FILES" ]; then
|
|
echo "❗️ Detected uncommitted changes after build (see diff output below)." >&2
|
|
echo "This indicates that the dist/ directory is out of sync with the checked-in index.js." >&2
|
|
echo "⭐️ If the changes below are expected, run 'npm run build:compile && npm run build:package' and commit the output files." >&2
|
|
# Run `git diff` for each line/file in $CHANGED_FILES:
|
|
echo "$CHANGED_FILES" | xargs -I {} git diff --ignore-space-at-eol --text -- {}
|
|
exit 1
|
|
else
|
|
echo "✅ No uncommitted changes detected after build."
|
|
fi
|
|
id: diff
|
|
|
|
# If index.js was different than expected, upload the expected version as an artifact
|
|
- uses: actions/upload-artifact@v4
|
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
|
with:
|
|
name: dist
|
|
path: dist/
|