check-dist.yml (1454B)
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/ 7 8 on: 9 push: 10 branches: 11 - main 12 paths-ignore: 13 - '**.md' 14 pull_request: 15 paths-ignore: 16 - '**.md' 17 workflow_dispatch: 18 19 jobs: 20 check-dist: 21 runs-on: ubuntu-latest 22 23 steps: 24 - uses: actions/checkout@v4 25 26 - name: Set Node.js 16.x 27 uses: actions/setup-node@v4.1.0 28 with: 29 node-version: 16.x 30 cache: npm 31 32 - name: Install dependencies 33 run: npm ci 34 35 - name: Rebuild the dist/ directory 36 run: | 37 npm run build 38 npm run package 39 40 - name: Compare the expected and actual dist/ directories 41 run: | 42 if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then 43 echo "Detected uncommitted changes after build. See status below:" 44 git diff 45 exit 1 46 fi 47 id: diff 48 49 # If index.js was different than expected, upload the expected version as an artifact 50 - uses: actions/upload-artifact@v4 51 if: ${{ failure() && steps.diff.conclusion == 'failure' }} 52 with: 53 name: dist 54 path: dist/