A GitHub Action that notifies developers only when dependabot pull requests fail checks and cannot be automerged.
When dependabot successfully automerges PRs, you don't need notifications. But when checks fail and manual intervention is needed, this action ensures the right people are notified immediately.
- ✅ Only triggers when workflow runs fail
- ✅ Only acts on dependabot PRs
- ✅ Supports both individual reviewers and team reviewers
- ✅ Customizable comment message
- ✅ Prevents duplicate notifications
Create a workflow file (e.g., .github/workflows/smart-dependabot-notifications.yml) that triggers on workflow run completion:
name: Smart Dependabot Notifications
on:
workflow_run:
workflows: ['CI', 'Tests'] # List your CI workflow names here
types:
- completed
jobs:
notify-on-failure:
runs-on: ubuntu-latest
permissions:
pull-requests: write
actions: read
steps:
- name: Add reviewers on failure
uses: dariacm/smart-dependabot-notifications@v1
with:
github-token: ${{ github.token }}
reviewers: 'daria,carlotta'
team-reviewers: 'backend-team,data-team'name: Smart Dependabot Notifications
on:
workflow_run:
workflows: ['CI', 'Lint', 'Tests']
types:
- completed
jobs:
notify-on-failure:
runs-on: ubuntu-latest
permissions:
pull-requests: write
actions: read
steps:
- name: Add reviewers on failure
uses: dariacm/smart-dependabot-notifications@v1
with:
github-token: ${{ github.token }}
reviewers: 'daria,carlotta'
team-reviewers: 'backend-team,data-team'
comment: '🚨 Dependabot PR failed checks. Please review!'If you have CODEOWNERS rules for files like package.json, package-lock.json, etc., GitHub will automatically assign those code owners as reviewers on every dependabot PR. This means:
- Your specified reviewers won't be added (action skips if reviewers already exist)
- CODEOWNERS get notified on ALL dependabot PRs, not just failures
- You lose the benefit of selective notifications
Recommended setup:
- Remove dependency files from CODEOWNERS
- Let this action handle dependabot notifications instead
| Input | Description | Required | Default |
|---|---|---|---|
github-token |
GitHub token with pull-requests:write permission. Pass ${{ github.token }} to use the default GitHub Actions token. |
Yes | - |
reviewers |
Comma-separated list of GitHub usernames | No | - |
team-reviewers |
Comma-separated list of GitHub team slugs | No | - |
comment |
Custom comment to post on PR when checks fail | No | dependabot was not able to automerge this pull request. Humans, please help 🤖 |
| Output | Description |
|---|---|
pull-request-number |
The number of the pull request that was processed |
reviewers-added |
The total number of reviewers (users + teams) that were added |
- Triggers on workflow_run completion: The action listens for completed workflow runs
- Checks actor: Verifies the workflow run was triggered by
dependabot[bot] - Checks conclusion: Only proceeds if the workflow run
conclusionisfailure - Finds associated PR: Gets the pull request associated with the workflow run
- Checks existing reviews: Skips if reviewers are already requested
- Adds reviewers: Requests reviews from specified users and/or teams
- Posts comment: Adds a comment to notify reviewers (prevents duplicates)
The action requires the following permissions:
permissions:
pull-requests: write # To request reviewers and post comments
actions: read # To retrieve workflow run details and verify dependabot triggered itNote: The actions: read permission is specifically needed to call the GitHub API's getWorkflowRun endpoint, which allows the action to check if the workflow was triggered by dependabot and if it failed.
- The action only works with
workflow_runevents - At least one of
reviewersorteam-reviewersmust be provided - The action will skip if reviewers are already requested to avoid spam
- Comments are deduplicated by exact body match
- If no PR is associated with the workflow run, the action will exit gracefully
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
If you want to contribute to this action:
- Clone the repository
- Install dependencies:
npm install - Make your changes to
index.js - Build the action:
npm run build - Commit both
index.jsanddist/index.js
The action uses @vercel/ncc to bundle the code and dependencies into a single file in the dist/ directory.
This project is distributed under the MIT license.