check-dist.yml 1.3 KB

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