Skip to content

Automate dist regeneration for Rolldown updates #2154

Automate dist regeneration for Rolldown updates

Automate dist regeneration for Rolldown updates #2154

Workflow file for this run

# `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 Transpiled JavaScript
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
inputs:
pr_number:
description: Pull request number used for concurrency
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ inputs.pr_number || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
- name: Enable Corepack
run: corepack enable
- name: Remove dist/ Directory
id: remove-dist
run: pnpm dlx rimraf ./dist
- name: Install dependencies
run: pnpm install
- name: Rebuild the dist/ directory
run: |
pnpm run all
# This will fail the workflow if the `dist/` directory is different than
# expected.
- name: Compare Directories
id: diff
run: |
if [ ! -d dist/ ]; then
echo "Expected dist/ directory does not exist. See status below:"
ls -la ./
exit 1
fi
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/