Skip to content

Add Dependabot lockfile fixer workflow#59

Merged
oleg-koval merged 1 commit intomainfrom
feat/dependabot-lockfile-fixer
Apr 4, 2026
Merged

Add Dependabot lockfile fixer workflow#59
oleg-koval merged 1 commit intomainfrom
feat/dependabot-lockfile-fixer

Conversation

@oleg-koval
Copy link
Copy Markdown
Owner

@oleg-koval oleg-koval commented Apr 4, 2026

Summary

Add a dedicated workflow to auto-repair stale package-lock.json files on same-repo Dependabot PRs.

Problem

This repository releases from CI and commits package-lock.json, so Dependabot PRs can drift behind main and fail with lockfile-only conflicts.

Solution

Run oleg-koval/dependabot-lockfile-fixer on Dependabot pull requests with a narrow pull_request_target workflow and same-repo guard.

Changes

  • add .github/workflows/dependabot-lockfile-fixer.yml
  • guard execution to dependabot[bot] and same-repo PR branches
  • use Node 24 and package_manager: npm
  • update the README maintenance note to mention automatic lockfile refresh
  • remove stale README wording about the completed master to main migration

Out of scope

  • fixing dependency incompatibilities
  • changing normal CI or release behavior
  • handling non-lockfile merge conflicts

Related issues

None

Validation

  • npm run docs:index:check

Screenshots / Demo

N/A

Risk and impact

Low. The workflow only runs for same-repo Dependabot PRs and only writes back to that PR branch.

Breaking changes

None

Documentation

Updated readme.md maintenance notes.

Reviewer notes

This is intentionally isolated from the regular CI and release workflows so the fix path stays limited to Dependabot lockfile drift.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 4, 2026

Warning

Rate limit exceeded

@oleg-koval has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 18 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 18 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 55b24ee2-ca96-42e1-818a-63aeac4d7006

📥 Commits

Reviewing files that changed from the base of the PR and between a2613af and aec2a24.

📒 Files selected for processing (2)
  • .github/workflows/dependabot-lockfile-fixer.yml
  • readme.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dependabot-lockfile-fixer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add Dependabot lockfile fixer workflow for npm

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add dedicated GitHub Actions workflow for auto-repairing Dependabot lockfiles
• Workflow runs on Dependabot PRs with same-repo guard and narrow scope
• Uses Node 24 and oleg-koval/dependabot-lockfile-fixer action
• Update README maintenance notes about automatic lockfile refresh
Diagram
flowchart LR
  A["Dependabot PR opened/updated"] -->|triggers| B["dependabot-lockfile-fixer workflow"]
  B -->|checks| C["Same-repo & dependabot[bot] actor"]
  C -->|if valid| D["Checkout PR branch"]
  D --> E["Setup Node.js 24"]
  E --> F["Run lockfile fixer"]
  F -->|commits| G["Auto-repair package-lock.json"]
Loading

Grey Divider

File Changes

1. .github/workflows/dependabot-lockfile-fixer.yml ⚙️ Configuration changes +45/-0

New Dependabot lockfile fixer workflow

• New workflow triggered on Dependabot PR events (opened, reopened, synchronize, ready_for_review)
• Includes guards to run only for dependabot[bot] actor and same-repo PRs
• Checks out PR branch, sets up Node.js 24, and runs oleg-koval/dependabot-lockfile-fixer action
• Configured with write permissions for contents and pull-requests

.github/workflows/dependabot-lockfile-fixer.yml


2. readme.md 📝 Documentation +2/-3

Update maintenance notes for lockfile automation

• Removed outdated wording about supporting both master and main branches
• Simplified maintenance notes to clarify stable releases from main and prereleases from beta
• Added note about automatic package-lock.json refresh via dedicated lockfile-fixer workflow

readme.md


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 4, 2026

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX Issues (0)

Grey Divider


Action required

1. Write token executes PR code 🐞 Bug ⛨ Security
Description
The new workflow runs on pull_request_target with contents: write, checks out the PR branch, and
then runs an npm-based lockfile fixer, meaning PR-controlled code paths (npm lifecycle scripts) can
execute with a write-scoped GITHUB_TOKEN. This can be abused to perform unintended repository
writes using that token.
Code

.github/workflows/dependabot-lockfile-fixer.yml[R3-45]

+on:
+  pull_request_target:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - ready_for_review
+
+permissions:
+  contents: write
+  pull-requests: write
+
+concurrency:
+  group: dependabot-lockfile-fixer-${{ github.event.pull_request.number }}
+  cancel-in-progress: true
+
+jobs:
+  fix-lockfiles:
+    if: >
+      github.actor == 'dependabot[bot]' &&
+      github.event.pull_request.head.repo.full_name == github.repository
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout PR branch
+        uses: actions/checkout@v4
+        with:
+          ref: ${{ github.event.pull_request.head.ref }}
+          repository: ${{ github.event.pull_request.head.repo.full_name }}
+          fetch-depth: 0
+          token: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: 24
+
+      - name: Fix lockfiles
+        uses: oleg-koval/dependabot-lockfile-fixer@v1
+        with:
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          package_manager: npm
+          working_directory: .
Evidence
The workflow is triggered via pull_request_target and grants write permissions, then explicitly
checks out the PR head ref and runs a lockfile fixer configured for npm. The repository’s
package.json defines an npm lifecycle script (prepare) that can run during installs,
demonstrating that running npm as part of lockfile regeneration can execute repository-defined
scripts in the checked-out PR workspace.

.github/workflows/dependabot-lockfile-fixer.yml[3-45]
package.json[59-68]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pull_request_target` workflows run with elevated permissions. This workflow checks out PR code and then runs an npm-based lockfile regeneration step while holding a write-scoped `GITHUB_TOKEN`, enabling PR-controlled execution paths (npm lifecycle scripts) to run with repository write access.

### Issue Context
You want to safely refresh lockfiles for same-repo Dependabot PRs without allowing PR-controlled code execution to access a write token.

### Fix Focus Areas
- .github/workflows/dependabot-lockfile-fixer.yml[3-45]
- package.json[59-68]

### Suggested remediation options
1) **Prefer `pull_request` over `pull_request_target`** if it still provides sufficient permissions for same-repo Dependabot branches in your repo.

2) If you must keep `pull_request_target`, **avoid running install scripts** during lockfile regeneration by replacing the third-party action with explicit commands that disable scripts, e.g.:
  - `npm ci --ignore-scripts` (or equivalent)
  - `npm install --package-lock-only --ignore-scripts`
  Then commit/push only `package-lock.json`.

3) **Use a tightly-scoped token** (GitHub App token / fine-grained PAT limited to pushing to the Dependabot PR branch) instead of a broadly-privileged default token.

4) **Minimize permissions** to only what is required to push the lockfile commit (typically `contents: write` only).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Action not pinned 🐞 Bug ⛨ Security
Description
The workflow uses oleg-koval/dependabot-lockfile-fixer@v1, which is a mutable tag, while running
with repository write permissions. If that tag is retargeted upstream, arbitrary code would execute
in this repo with contents: write.
Code

.github/workflows/dependabot-lockfile-fixer.yml[R40-43]

+      - name: Fix lockfiles
+        uses: oleg-koval/dependabot-lockfile-fixer@v1
+        with:
+          github_token: ${{ secrets.GITHUB_TOKEN }}
Evidence
The workflow grants write permissions and invokes a third-party action via a major-version tag
(@v1) rather than an immutable commit SHA, creating a supply-chain risk under write-scoped
credentials.

.github/workflows/dependabot-lockfile-fixer.yml[11-13]
.github/workflows/dependabot-lockfile-fixer.yml[40-45]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Using `uses: <owner>/<repo>@v1` is mutable and can change over time. With write permissions, this becomes a supply-chain risk.

### Issue Context
This workflow has `contents: write` and passes `GITHUB_TOKEN` into the action.

### Fix Focus Areas
- .github/workflows/dependabot-lockfile-fixer.yml[11-13]
- .github/workflows/dependabot-lockfile-fixer.yml[40-45]

### How to fix
- Replace `olek-koval/dependabot-lockfile-fixer@v1` with a **pinned commit SHA** (optionally keep the tag in a comment for readability), e.g.:
 - `uses: oleg-koval/dependabot-lockfile-fixer@<full_sha>`
- (Optional) Add a periodic dependency update process for action SHAs so upgrades are intentional and reviewed.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. README release branches wrong 🐞 Bug ⚙ Maintainability
Description
README now says stable releases publish from main only, but the repo’s release configuration and
documentation still define both master and main as stable release branches. This inconsistency
will mislead maintainers about actual release behavior during the branch migration window.
Code

readme.md[R118-120]

- Consumer-facing examples now use `main`.
-- Repository automation currently supports both `master` and `main` so maintenance is not blocked before the branch rename.
-- Repository automation also supports `beta` for prerelease validation and publishing.
-- Renaming this repository's default branch to `main` is still recommended to align hosted defaults, badges, and examples.
+- Repository automation publishes stable releases from `main` and prereleases from `beta`.
+- Dependabot PRs can auto-refresh `package-lock.json` through the dedicated lockfile-fixer workflow.
Evidence
README claims stable releases from main, but release.repo.config.js, tests, and docs explicitly
include both master and main as stable branches, and the publish workflow still triggers on
pushes to master as well.

readme.md[116-121]
release.repo.config.js[1-10]
docs/release-channels.md[1-8]
test/release-config.test.js[47-53]
.github/workflows/release.yml[3-9]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
README states stable releases come from `main`, but repo configuration still treats both `master` and `main` as stable release branches.

### Issue Context
This repo appears to be in a migration window where both branches are supported.

### Fix Focus Areas
- readme.md[116-121]
- release.repo.config.js[1-10]
- docs/release-channels.md[1-8]
- test/release-config.test.js[47-53]
- .github/workflows/release.yml[3-9]

### How to fix
Choose one:
1) **If you still support `master`**: update README maintenance note to say stable releases publish from **both `master` and `main`** (and keep `beta` for prereleases).

2) **If `master` support is removed**: update the actual automation/config to match the README by removing `master` from:
  - `.github/workflows/release.yml` branch triggers
  - `release.repo.config.js` branches
  - docs/tests that assert `master` is stable.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@oleg-koval oleg-koval merged commit 287745b into main Apr 4, 2026
6 checks passed
@oleg-koval oleg-koval deleted the feat/dependabot-lockfile-fixer branch April 4, 2026 15:24
github-actions Bot pushed a commit that referenced this pull request Apr 4, 2026
## [1.7.1](v1.7.0...v1.7.1) (2026-04-04)

### ⚙️ Continuous Integrations

* **dependabot:** add lockfile fixer workflow ([#59](#59)) ([287745b](287745b))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2026

🎉 This PR is included in version 1.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Comment on lines +3 to +45
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
- ready_for_review

permissions:
contents: write
pull-requests: write

concurrency:
group: dependabot-lockfile-fixer-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
fix-lockfiles:
if: >
github.actor == 'dependabot[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest

steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24

- name: Fix lockfiles
uses: oleg-koval/dependabot-lockfile-fixer@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
package_manager: npm
working_directory: .
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Write token executes pr code 🐞 Bug ⛨ Security

The new workflow runs on pull_request_target with contents: write, checks out the PR branch, and
then runs an npm-based lockfile fixer, meaning PR-controlled code paths (npm lifecycle scripts) can
execute with a write-scoped GITHUB_TOKEN. This can be abused to perform unintended repository
writes using that token.
Agent Prompt
### Issue description
`pull_request_target` workflows run with elevated permissions. This workflow checks out PR code and then runs an npm-based lockfile regeneration step while holding a write-scoped `GITHUB_TOKEN`, enabling PR-controlled execution paths (npm lifecycle scripts) to run with repository write access.

### Issue Context
You want to safely refresh lockfiles for same-repo Dependabot PRs without allowing PR-controlled code execution to access a write token.

### Fix Focus Areas
- .github/workflows/dependabot-lockfile-fixer.yml[3-45]
- package.json[59-68]

### Suggested remediation options
1) **Prefer `pull_request` over `pull_request_target`** if it still provides sufficient permissions for same-repo Dependabot branches in your repo.

2) If you must keep `pull_request_target`, **avoid running install scripts** during lockfile regeneration by replacing the third-party action with explicit commands that disable scripts, e.g.:
   - `npm ci --ignore-scripts` (or equivalent)
   - `npm install --package-lock-only --ignore-scripts`
   Then commit/push only `package-lock.json`.

3) **Use a tightly-scoped token** (GitHub App token / fine-grained PAT limited to pushing to the Dependabot PR branch) instead of a broadly-privileged default token.

4) **Minimize permissions** to only what is required to push the lockfile commit (typically `contents: write` only).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +40 to +43
- name: Fix lockfiles
uses: oleg-koval/dependabot-lockfile-fixer@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Action not pinned 🐞 Bug ⛨ Security

The workflow uses oleg-koval/dependabot-lockfile-fixer@v1, which is a mutable tag, while running
with repository write permissions. If that tag is retargeted upstream, arbitrary code would execute
in this repo with contents: write.
Agent Prompt
### Issue description
Using `uses: <owner>/<repo>@v1` is mutable and can change over time. With write permissions, this becomes a supply-chain risk.

### Issue Context
This workflow has `contents: write` and passes `GITHUB_TOKEN` into the action.

### Fix Focus Areas
- .github/workflows/dependabot-lockfile-fixer.yml[11-13]
- .github/workflows/dependabot-lockfile-fixer.yml[40-45]

### How to fix
- Replace `olek-koval/dependabot-lockfile-fixer@v1` with a **pinned commit SHA** (optionally keep the tag in a comment for readability), e.g.:
  - `uses: oleg-koval/dependabot-lockfile-fixer@<full_sha>`
- (Optional) Add a periodic dependency update process for action SHAs so upgrades are intentional and reviewed.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

oleg-koval added a commit that referenced this pull request Apr 4, 2026
* ci(dependabot): add lockfile fixer workflow (#59)

* release(version): Release 1.7.1 [skip ci]

## [1.7.1](v1.7.0...v1.7.1) (2026-04-04)

### ⚙️ Continuous Integrations

* **dependabot:** add lockfile fixer workflow ([#59](#59)) ([287745b](287745b))

* docs(readme): refresh badges and branch guidance (#58)

* release(version): Release 1.7.2 [skip ci]

## [1.7.2](v1.7.1...v1.7.2) (2026-04-04)

### 📚 Documentation

* **readme:** refresh badges and branch guidance ([#58](#58)) ([5b82595](5b82595))

* fix(ci): run lockfile fixer for reopened dependabot prs

* fix(ci): run lockfile fixer for reopened dependabot prs

* ci(dependabot): auto-merge safe npm updates

* docs(release): clarify branch migration and defaults

* release(version): Release 1.7.3 [skip ci]

## [1.7.3](v1.7.2...v1.7.3) (2026-04-04)

### 🐛 Bug Fixes

* **ci:** run lockfile fixer for reopened dependabot prs ([cea37bf](cea37bf))

---------

Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
oleg-koval added a commit that referenced this pull request Apr 4, 2026
…dates (#61)

* ci(dependabot): add lockfile fixer workflow (#59)

* release(version): Release 1.7.1 [skip ci]

## [1.7.1](v1.7.0...v1.7.1) (2026-04-04)

### ⚙️ Continuous Integrations

* **dependabot:** add lockfile fixer workflow ([#59](#59)) ([287745b](287745b))

* docs(readme): refresh badges and branch guidance (#58)

* release(version): Release 1.7.2 [skip ci]

## [1.7.2](v1.7.1...v1.7.2) (2026-04-04)

### 📚 Documentation

* **readme:** refresh badges and branch guidance ([#58](#58)) ([5b82595](5b82595))

* fix(ci): run lockfile fixer for reopened dependabot prs

* fix(ci): run lockfile fixer for reopened dependabot prs

* ci(dependabot): auto-merge safe npm updates

* docs(release): clarify branch migration and defaults

* release(version): Release 1.7.3 [skip ci]

## [1.7.3](v1.7.2...v1.7.3) (2026-04-04)

### 🐛 Bug Fixes

* **ci:** run lockfile fixer for reopened dependabot prs ([cea37bf](cea37bf))

* chore(deps): bump the npm_and_yarn group across 1 directory with 3 updates

Bumps the npm_and_yarn group with 3 updates in the / directory: [braces](https://github.com/micromatch/braces), [lodash](https://github.com/lodash/lodash) and [picomatch](https://github.com/micromatch/picomatch).


Updates `braces` from 3.0.2 to 3.0.3
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

Updates `lodash` from 4.17.21 to 4.18.1
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.21...4.18.1)

Updates `picomatch` from 2.3.0 to 2.3.2
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](micromatch/picomatch@2.3.0...2.3.2)

---
updated-dependencies:
- dependency-name: braces
  dependency-version: 3.0.3
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: lodash
  dependency-version: 4.18.1
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: picomatch
  dependency-version: 2.3.2
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: oleg koval <5700359+oleg-koval@users.noreply.github.com>
Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
github-actions Bot pushed a commit that referenced this pull request Apr 4, 2026
## [1.7.4-beta.1](v1.7.3...v1.7.4-beta.1) (2026-04-04)

### ♻️ Chores

* **deps:** bump the npm_and_yarn group across 1 directory with 3 updates ([#61](#61)) ([82f69fc](82f69fc)), closes [#59](#59) [#58](#58)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant