From 41e630fae5aff714701c58478e5628b9d5a1e2f2 Mon Sep 17 00:00:00 2001 From: Silvio Vasiljevic Date: Thu, 29 Oct 2026 15:29:27 +0100 Subject: [PATCH] Rebuild dist/ automatically on Dependabot PRs Dependabot bumps of bundled dependencies (e.g. undici) always failed the "Check dist/" job until someone rebuilt dist/ by hand. Build dist/ in a read-only job with install scripts disabled, then push it back to the PR branch from a separate job that runs no npm code. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/dependabot-dist.yml | 92 +++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/dependabot-dist.yml diff --git a/.github/workflows/dependabot-dist.yml b/.github/workflows/dependabot-dist.yml new file mode 100644 index 0000000..a890218 --- /dev/null +++ b/.github/workflows/dependabot-dist.yml @@ -0,0 +1,92 @@ +# Dependabot updates package-lock.json but never rebuilds dist/, so every bump +# of a bundled dependency fails the "Check dist/" job. This workflow rebuilds +# dist/ on Dependabot PRs and pushes the result back to the PR branch. +# +# The build runs without write access and without dependency install scripts; +# only the job that pushes gets a write token, and it runs no npm code. +# +# Pushes made with GITHUB_TOKEN do not trigger new workflow runs, so the new +# head commit shows no checks. CI runs again on main after merging. +name: Rebuild dist/ for Dependabot + +on: + pull_request: + +permissions: {} + +concurrency: + group: dependabot-dist-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + build: + name: Build dist/ + if: github.event.pull_request.user.login == 'dependabot[bot]' + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Setup Node.js + id: setup-node + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version-file: .node-version + cache: npm + + - name: Install Dependencies + id: install + run: npm ci --ignore-scripts + + - name: Build dist/ Directory + id: build + run: npm run bundle + + - name: Upload Artifact + id: upload + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: dist + path: dist/ + + commit: + name: Commit dist/ + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.ref }} + # needed for the push below; this job runs no dependency code + persist-credentials: true # zizmor: ignore[artipacked] + + - name: Download Artifact + id: download + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: dist + path: dist/ + + - name: Commit and Push + id: push + run: | + if git diff --quiet -- dist/; then + echo "dist/ is already up to date" + exit 0 + fi + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + git add dist/ + git commit -m 'Rebuild dist/' + git push