GitHub Actions Dependabot Updates
Modern projects rely on dozens of outside packages, and every workflow relies on marketplace actions. Old versions collect bugs and security holes. Dependabot watches those dependencies and opens pull requests when newer versions appear.
Dependabot in Simple Words
Imagine a pantry assistant who checks expiry dates every week. The assistant never throws anything away without asking. A note appears on your desk that says "the milk expires soon, replace it?" Dependabot writes that note as a pull request, and you decide whether to accept it.
Three Dependabot Features
| Feature | Purpose |
|---|---|
| Dependabot alerts | Warn about known vulnerabilities in your dependencies |
| Security updates | Open pull requests that fix vulnerable packages |
| Version updates | Open pull requests that keep packages current on a schedule |
Turn on alerts and security updates under Settings, then Code security. Version updates need a configuration file.
The Update Cycle
+-------------+ +-----------------+ +---------------+ +-----------+
| Dependabot | --> | Opens a pull | --> | Your CI | --> | You merge |
| checks | | request with | | workflow | | or close |
| weekly | | the new version | | runs tests | | |
+-------------+ +-----------------+ +---------------+ +-----------+Create the Configuration File
Place a file named dependabot.yml inside the .github folder.
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5Understanding the Settings
package-ecosystem
This value names the package manager. Common choices include npm, pip, maven, docker, nuget, and github-actions.
directory
The directory points to the folder with the manifest file, such as package.json. For the github-actions ecosystem, use / and Dependabot scans .github/workflows.
schedule
The interval accepts daily, weekly, or monthly. Weekly keeps noise low for most teams.
open-pull-requests-limit
This number caps how many update pull requests stay open at once.
Keeping Actions Fresh
The github-actions ecosystem updates lines such as uses: actions/checkout@v3 to newer versions. Workflows stay secure and compatible without manual checking.
Before: uses: actions/checkout@v3
After: uses: actions/checkout@v4 (opened by Dependabot)Group Updates to Reduce Noise
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
groups:
dev-tools:
patterns:
- "eslint*"
- "prettier"Grouped updates arrive as a single pull request instead of many small ones.
Workflows Triggered by Dependabot
Pull requests from Dependabot start your normal CI workflow. Two special rules apply. The token has read-only access by default. Regular repository secrets stay hidden, and Dependabot uses its own separate secret store under Settings, then Secrets and variables, then Dependabot.
Auto-Merge for Safe Updates
Teams often merge minor and patch updates automatically after tests pass.
name: Dependabot Auto-Merge
on: pull_request
permissions:
contents: write
pull-requests: write
jobs:
automerge:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Enable auto-merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"Auto-merge waits for required checks, so failing tests block the merge. Enable branch protection with required status checks before using this workflow. The repository setting Allow auto-merge must be on.
Good Habits
- Read the release notes that Dependabot includes in each pull request.
- Require passing tests before any merge.
- Review major version updates by hand, since they may break behavior.
- Review the update schedule every few months and adjust the noise level.
