Skip to content

Commit 1e40cc3

Browse files
authored
ci: add merge queue support and 7-day Dependabot auto-merge soak period (#53)
- Add merge_group trigger to ci.yml and codeql.yml so CI runs on merge queue branches (required for queue to function) - Remove immediate auto-merge from dependabot-compat.yml; keep approve only - Add dependabot-automerge.yml: scheduled daily job that enables auto-merge on Dependabot PRs that are >= 7 days old, approved, and not yet queued - Major version updates still require manual review
1 parent 666d7f8 commit 1e40cc3

4 files changed

Lines changed: 73 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [main, develop]
66
pull_request:
77
branches: [main]
8+
merge_group:
89

910
concurrency:
1011
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/codeql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8+
merge_group:
89
schedule:
910
- cron: '30 2 * * 1'
1011

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Dependabot Auto-merge (7-day soak)
2+
3+
# Runs daily. For any open Dependabot PR that is >= 7 days old, approved, and
4+
# has passing CI — enables auto-merge so the merge queue picks it up.
5+
6+
on:
7+
schedule:
8+
- cron: '0 9 * * *' # 09:00 UTC daily
9+
workflow_dispatch: # allow manual trigger for testing
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
automerge:
17+
name: Auto-merge
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Merge eligible Dependabot PRs
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
REPO: ${{ github.repository }}
24+
run: |
25+
SEVEN_DAYS_AGO=$(date -u -d '7 days ago' '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null || \
26+
date -u -v-7d '+%Y-%m-%dT%H:%M:%SZ')
27+
28+
echo "Looking for Dependabot PRs opened before $SEVEN_DAYS_AGO ..."
29+
30+
gh pr list \
31+
--repo "$REPO" \
32+
--author "app/dependabot" \
33+
--state open \
34+
--json number,title,createdAt,reviewDecision,autoMergeRequest \
35+
| jq -c '.[]' \
36+
| while IFS= read -r pr; do
37+
NUMBER=$(echo "$pr" | jq -r '.number')
38+
TITLE=$(echo "$pr" | jq -r '.title')
39+
CREATED=$(echo "$pr" | jq -r '.createdAt')
40+
REVIEW=$(echo "$pr" | jq -r '.reviewDecision')
41+
ALREADY=$(echo "$pr" | jq -r '.autoMergeRequest')
42+
43+
# Skip if already queued for auto-merge
44+
if [ "$ALREADY" != "null" ]; then
45+
echo "PR #$NUMBER — already has auto-merge set, skipping"
46+
continue
47+
fi
48+
49+
# Skip if not yet approved
50+
if [ "$REVIEW" != "APPROVED" ]; then
51+
echo "PR #$NUMBER — not approved yet ($REVIEW), skipping"
52+
continue
53+
fi
54+
55+
# Skip if less than 7 days old
56+
if [[ "$CREATED" > "$SEVEN_DAYS_AGO" ]]; then
57+
echo "PR #$NUMBER — opened $CREATED, not yet 7 days old, skipping"
58+
continue
59+
fi
60+
61+
echo "PR #$NUMBER ($TITLE) — eligible, enabling auto-merge"
62+
gh pr merge --auto --squash "$NUMBER" --repo "$REPO" || \
63+
echo "PR #$NUMBER — auto-merge failed (may already be queued)"
64+
done

.github/workflows/dependabot-compat.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,11 @@ jobs:
254254
}
255255
echo "✓ No incompatible npm licenses detected"
256256
257-
# ---- Auto-approve and auto-merge safe updates ----
258-
auto-merge:
257+
# ---- Auto-approve safe updates ----
258+
# Auto-merge is intentionally NOT triggered here — the 7-day soak period is
259+
# enforced by dependabot-automerge.yml (scheduled daily). Major updates are
260+
# left for manual review regardless.
261+
auto-approve:
259262
name: Auto-merge
260263
needs: [go-compat, npm-compat, actions-compat, security, license]
261264
if: |
@@ -273,15 +276,9 @@ jobs:
273276
with:
274277
github-token: ${{ secrets.GITHUB_TOKEN }}
275278

276-
- name: Approve PR
277-
run: gh pr review --approve "$PR_URL"
278-
env:
279-
PR_URL: ${{ github.event.pull_request.html_url }}
280-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
281-
282-
- name: Auto-merge patch and minor updates
279+
- name: Approve patch and minor updates
283280
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
284-
run: gh pr merge --auto --squash "$PR_URL"
281+
run: gh pr review --approve "$PR_URL"
285282
env:
286283
PR_URL: ${{ github.event.pull_request.html_url }}
287284
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)