Skip to content

Commit 2cfc2fd

Browse files
ci: auto-approve Dependabot pull requests
1 parent 2db4b15 commit 2cfc2fd

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Automatically approve Dependabot dependency-update pull requests.
2+
# Runs in the base repository context; it never checks out untrusted PR code.
3+
name: Auto-approve Dependabot pull requests
4+
5+
on:
6+
pull_request_target:
7+
types: [opened, reopened, synchronize]
8+
schedule:
9+
- cron: '17 * * * *'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
jobs:
17+
approve:
18+
name: Approve Dependabot PRs
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Approve open Dependabot pull requests
22+
env:
23+
GH_TOKEN: ${{ github.token }}
24+
REPOSITORY: ${{ github.repository }}
25+
run: |
26+
set -euo pipefail
27+
gh api --paginate \
28+
"/repos/${REPOSITORY}/pulls?state=open&per_page=100" \
29+
--jq '.[] | select(.user.login == "dependabot[bot]") | .number' \
30+
| while read -r pr; do
31+
[ -n "$pr" ] || continue
32+
echo "Approving Dependabot PR #$pr"
33+
gh pr review "$pr" --repo "$REPOSITORY" --approve \
34+
--body "Automatically approved by the organization Dependabot policy."
35+
done

0 commit comments

Comments
 (0)