Skip to content

Commit d2bab96

Browse files
authored
Add Dependabot auto approve workflow (#286)
## Overview Changes: * Added a workflow for automatically approving and merging **patch** and **minor** Dependabot updates. * Reduced the frequency of updates (now "quarterly") ## Related Issue / Discussion I've configured a method of Dependabot gaining an access token via the Birdhouse Helper Bot. This secret is only accessible to Pull Requests opened by Dependabot. This workflow has been implemented for Ouranos repositories without issues. ## Additional Information This change is being made to address the following announcement: > Beginning January 27, 2026, Dependabot will no longer support the https://github.com/dependabot merge command. Please use GitHub's native pull request controls instead. Please see the [changelog announcement](https://github.blog/changelog/2025-10-06-upcoming-changes-to-github-dependabot-pull-request-comment-commands/) for additional details.
2 parents 0866ff2 + 595d15e commit d2bab96

File tree

2 files changed

+90
-6
lines changed

2 files changed

+90
-6
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@
66
version: 2
77
updates:
88
- package-ecosystem: github-actions
9-
directory: /
9+
directory: /.github/workflows
1010
schedule:
11-
interval: monthly
11+
interval: "quarterly"
1212
groups:
1313
actions:
1414
patterns:
1515
- "*"
16+
update-types:
17+
- patch
18+
- minor
19+
- major
1620

1721
- package-ecosystem: pip
1822
directory: /
1923
schedule:
20-
interval: monthly
24+
interval: "quarterly"
2125
groups:
22-
ci:
23-
patterns:
24-
- "CI/*"
2526
python:
2627
patterns:
2728
- "requirements*.txt"
29+
update-types:
30+
- patch
31+
- minor
32+
- major
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Dependabot CI Updates
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- opened
9+
- synchronize
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
dependabot-auto-approve:
16+
name: Auto-approve and auto-merge safe Dependabot updates
17+
runs-on: ubuntu-latest
18+
if: >
19+
github.event.pull_request.user.login == 'dependabot[bot]' &&
20+
contains(github.event.pull_request.labels.*.name, 'dependencies')
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
steps:
25+
- name: Harden Runner
26+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
27+
with:
28+
disable-sudo: true
29+
egress-policy: audit
30+
31+
- name: Generate GitHub App token
32+
id: token_generator
33+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
34+
with:
35+
app-id: ${{ secrets.BIRDHOUSE_HELPER_BOT_ID }}
36+
private-key: ${{ secrets.BIRDHOUSE_HELPER_BOT_KEY }}
37+
38+
- name: Fetch Dependabot metadata
39+
id: dependabot-metadata
40+
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
41+
with:
42+
github-token: ${{ steps.token_generator.outputs.token }}
43+
44+
- name: Stop workflow if not minor update or patch update
45+
id: skip-condition
46+
if: >
47+
steps.dependabot-metadata.outputs.update-type != 'version-update:semver-minor' &&
48+
steps.dependabot-metadata.outputs.update-type != 'version-update:semver-patch'
49+
run: |
50+
echo "Not a minor or patch update; skipping auto-approval."
51+
echo "skip=true" >> $GITHUB_OUTPUT
52+
53+
- name: Checkout Repository
54+
if: steps.skip-condition.outputs.skip != 'true'
55+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
56+
with:
57+
persist-credentials: false
58+
token: ${{ steps.token_generator.outputs.token }}
59+
60+
- name: Approve Changes
61+
if: steps.skip-condition.outputs.skip != 'true'
62+
run: |
63+
decision="$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)"
64+
if [ "$decision" != "APPROVED" ]; then
65+
gh pr review --approve "$PR_URL"
66+
else
67+
echo "PR already approved: skipping approval."
68+
fi
69+
env:
70+
GITHUB_TOKEN: ${{ steps.token_generator.outputs.token }}
71+
PR_URL: ${{ github.event.pull_request.html_url }}
72+
73+
- name: Enable auto-merge on Pull Request
74+
if: steps.skip-condition.outputs.skip != 'true'
75+
run: |
76+
gh pr merge --auto --merge "$PR_URL"
77+
env:
78+
GITHUB_TOKEN: ${{ steps.token_generator.outputs.token }}
79+
PR_URL: ${{ github.event.pull_request.html_url }}

0 commit comments

Comments
 (0)