-
Notifications
You must be signed in to change notification settings - Fork 27
67 lines (59 loc) · 2.14 KB
/
Copy pathpr-autoupdate.yml
File metadata and controls
67 lines (59 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Auto-update open PRs targeting testing when testing advances.
# Prevents the BEHIND state that blocks auto-merge from triggering.
# Runs after every push to testing (including merge-queue squash commits).
# Non-destructive: gh pr update-branch merges testing in; conflicts stay open.
name: PR Auto-update
on:
push:
branches:
- testing
concurrency:
group: pr-autoupdate
cancel-in-progress: true
jobs:
update-stale-prs:
name: Update stale PRs targeting testing
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
pull-requests: write
steps:
- name: Find and update stale PRs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
# Find all open PRs targeting testing that are BEHIND and need updating.
# Renovate manages its own branch updates — skip them.
# Mergeraptor PRs (distrobox, junction bumps) DO target testing and need auto-update
# so renovate-automerge can fire. They are intentionally included here.
STALE_PRS=$(gh pr list \
--repo "$REPO" \
--base testing \
--state open \
--json number,headRefName,mergeStateStatus,author \
--jq '
.[] |
select(.mergeStateStatus == "BEHIND") |
select(.author.login != "renovate[bot]") |
.number
')
if [ -z "$STALE_PRS" ]; then
echo "No stale PRs found — nothing to do"
exit 0
fi
echo "Stale PRs to update: $(echo "$STALE_PRS" | tr '\n' ' ')"
UPDATED=0
SKIPPED=0
for PR_NUM in $STALE_PRS; do
if gh pr update-branch "$PR_NUM" --repo "$REPO" 2>/dev/null; then
echo " ✅ PR #${PR_NUM} updated"
UPDATED=$((UPDATED + 1))
else
echo " ⚠️ PR #${PR_NUM} skipped (already up-to-date or merge conflict)"
SKIPPED=$((SKIPPED + 1))
fi
done
echo "Done — updated: ${UPDATED}, skipped: ${SKIPPED}"