Dependency review action on main branch? #169257
Replies: 1 comment
-
Should Dependency Review Action run on PRs or on push to main?Short answer: run it on pull_request. That’s where it prevents risky dependency changes from getting merged. Running it on push to main is optional and mostly useful for visibility when you allow direct pushes or want post-merge auditing. TL;DR
Why run on pull_request
When to also run on push to main
Recommended Workflow Examples1) PR-only (recommended for most teams)Triggers only when dependency manifests/lockfiles change. name: Dependency Review (PR)
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- '**/package-lock.json'
- '**/pnpm-lock.yaml'
- '**/yarn.lock'
- '**/requirements.txt'
- '**/Pipfile.lock'
- '**/poetry.lock'
- '**/Gemfile.lock'
- '**/pom.xml'
- '**/build.gradle'
- '**/build.gradle.kts'
- '**/go.sum'
- '**/Cargo.lock'
permissions:
contents: read
jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/dependency-review-action@v4
with:
# Fail the check when new vulns at or above this severity appear
fail-on-severity: high 2) PR + push to default branch (for direct pushes / extra auditing)Adds a second trigger for pushes to main. This won’t block changes already merged, but it surfaces issues on the main branch. name: Dependency Review (PR + Main)
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- '**/package-lock.json'
- '**/pnpm-lock.yaml'
- '**/yarn.lock'
- '**/requirements.txt'
- '**/Pipfile.lock'
- '**/poetry.lock'
- '**/Gemfile.lock'
- '**/pom.xml'
- '**/build.gradle'
- '**/build.gradle.kts'
- '**/go.sum'
- '**/Cargo.lock'
push:
branches: [main]
paths:
- '**/package-lock.json'
- '**/pnpm-lock.yaml'
- '**/yarn.lock'
- '**/requirements.txt'
- '**/Pipfile.lock'
- '**/poetry.lock'
- '**/Gemfile.lock'
- '**/pom.xml'
- '**/build.gradle'
- '**/build.gradle.kts'
- '**/go.sum'
- '**/Cargo.lock'
permissions:
contents: read
jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/dependency-review-action@v4
with:
fail-on-severity: high Practical tips
Human summaryIf your team merges everything through PRs, just run Dependency Review on pull_request and call it a day. If people sometimes push straight to main (or you want that extra belt-and-suspenders audit), add a push trigger for main too. The real value is in catching problems before merge—so PRs first, push-to-main only if you really need it. References
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Question
What GitHub Actions topic or product is this about?
Misc
Discussion Details
Is the dependency review action intended only for pull requests? It's technically runnable on the
main
/master
branches too when PRs merge, but is there any benefit? It appears to be merely a reporting tool, leaving a comment in the PR that runs it, and that report is accessible for pushes tomain
/master
too if you know where to look, but I'm not sure if anything is lost by disabling it on those branches.Beta Was this translation helpful? Give feedback.
All reactions