diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 99c1f04..12ed497 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -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 TypeScript 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,34 +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@v3 - - 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-file: .node-version + cache: npm - - name: Install dependencies + - name: Install Dependencies + id: install run: npm ci - - name: Rebuild the dist/ directory - run: | - npm run build - npm run package + - 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:" + echo "Detected uncommitted changes after build. See status below:" git diff 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: