Files

57 lines
1.6 KiB
YAML

# Inspired by @action/checkout
#
# Compares the checked in `dist/index.js` with the PR's `dist/index.js`
# On mismatch this action fails
name: Verify dist
on:
push:
branches:
- master
- release/**
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
jobs:
check-dist:
name: Verify dist/index.js file
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Use volta
uses: volta-cli/action@5c175f92dea6f48441c436471e6479dbc192e194 # v4
- name: Install dependencies
run: yarn install
- name: Rebuild dist
run: yarn build
- name: Compare expected and actual dist
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo 'Detected uncommitted changes after build. Did you forget to commit dist/?'
echo "Diff:"
git diff dist/
exit 1
fi
# ncc emits code-split chunks (e.g. dist/319.index.js) next to index.js
# whenever a dependency uses a dynamic import. A new chunk shows up as an
# untracked file, which `git diff` does not report, so check for it too.
untracked="$(git ls-files --others --exclude-standard dist/)"
if [ -n "$untracked" ]; then
echo 'Detected untracked files in dist/ after build. Did you forget to commit them?'
echo "$untracked"
exit 1
fi