diff --git a/.github/workflows/dependabot-fix-lockfile.yml b/.github/workflows/dependabot-fix-lockfile.yml new file mode 100644 index 0000000..4a13af8 --- /dev/null +++ b/.github/workflows/dependabot-fix-lockfile.yml @@ -0,0 +1,46 @@ +name: Fix Dependabot lockfile + +on: + pull_request: + branches: [main, next] + +permissions: + contents: write + pull-requests: read + +jobs: + fix-lockfile: + name: Fix lockfile + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 + with: + egress-policy: audit + + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + with: + node-version: 22 + + - name: Regenerate lockfile + run: npm install --package-lock-only --ignore-scripts + + - name: Commit updated lockfile + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add package-lock.json + if git diff --cached --quiet; then + echo "Lockfile is already in sync" + else + git commit -m "fix: regenerate package-lock.json" + git push + fi