Skip to content

Commit dd1a981

Browse files
committed
chore: add reviewers to dependabot prs
Signed-off-by: Taylor Price <[email protected]>
1 parent 46ed634 commit dd1a981

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Request reviewers for Dependabot PRs
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened, ready_for_review]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
request_reviewers:
12+
# Only run for Dependabot-authored PRs
13+
if: ${{ github.actor == 'dependabot[bot]' }}
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Request reviewers
18+
env:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
OWNER: ${{ github.repository_owner }}
21+
REPO: ${{ github.event.repository.name }}
22+
PR_NUMBER: ${{ github.event.pull_request.number }}
23+
24+
# --- Configure these ---
25+
# Individual users (GitHub usernames), comma-separated
26+
REVIEWERS: "njhale,g-linville,thedadams"
27+
28+
# Teams in your org (team slugs, not display names), comma-separated
29+
TEAM_REVIEWERS: ""
30+
shell: bash
31+
run: |
32+
set -euo pipefail
33+
34+
# Convert comma-separated strings to JSON arrays
35+
reviewers_json=$(python - <<'PY'
36+
import os, json
37+
s=os.getenv("REVIEWERS","").strip()
38+
arr=[x.strip() for x in s.split(",") if x.strip()]
39+
print(json.dumps(arr))
40+
PY
41+
)
42+
43+
team_reviewers_json=$(python - <<'PY'
44+
import os, json
45+
s=os.getenv("TEAM_REVIEWERS","").strip()
46+
arr=[x.strip() for x in s.split(",") if x.strip()]
47+
print(json.dumps(arr))
48+
PY
49+
)
50+
51+
payload=$(python - <<PY
52+
import json
53+
print(json.dumps({
54+
"reviewers": json.loads('''$reviewers_json'''),
55+
"team_reviewers": json.loads('''$team_reviewers_json'''),
56+
}))
57+
PY
58+
)
59+
60+
echo "Requesting reviewers for PR #${PR_NUMBER} in ${OWNER}/${REPO}"
61+
curl -sS -X POST \
62+
-H "Authorization: Bearer ${GH_TOKEN}" \
63+
-H "Accept: application/vnd.github+json" \
64+
"https://api.github.com/repos/${OWNER}/${REPO}/pulls/${PR_NUMBER}/requested_reviewers" \
65+
-d "${payload}"

0 commit comments

Comments
 (0)