-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (57 loc) · 2.41 KB
/
Copy pathmerge-schedule.yml
File metadata and controls
68 lines (57 loc) · 2.41 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
68
name: Scheduled Merge Reminder
# Posts a reminder comment on a PR when its scheduled merge date arrives.
# Triggered by `/remind YYYY-MM-DD` (or the legacy `/schedule YYYY-MM-DD`)
# in the PR body. The comment @-mentions the author (and assignee, if set)
# asking them to enable auto-merge manually so the merge_group event fires
# under a human actor and CI runs on the queued ref.
#
# Usage: add this line anywhere in the PR description:
# /remind 2026-05-15
#
# Will require setting a schedule on the Github Action in the repo, for example:
# on:
# schedule:
# - cron: '0 14 * * *' # 10am EDT / 9am EST
on:
workflow_call:
permissions:
pull-requests: write
jobs:
remind-scheduled-prs:
runs-on: ubuntu-latest
steps:
- name: Post reminders for due PRs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
TODAY=$(TZ='America/New_York' date +%Y-%m-%d)
echo "Today (Eastern): $TODAY"
pr_numbers=$(
gh pr list --repo "$REPO" --state open --json number,body \
--jq '[.[] | select(.body | test("/(remind|schedule) [0-9]{4}-[0-9]{2}-[0-9]{2}"))] | .[].number'
)
if [[ -z "$pr_numbers" ]]; then
echo "No scheduled PRs found."
exit 0
fi
for pr in $pr_numbers; do
pr_json=$(gh pr view "$pr" --repo "$REPO" --json body,author,assignees)
body=$(printf '%s' "$pr_json" | jq -r '.body')
scheduled=$(printf '%s' "$body" | grep -oP '/(remind|schedule) \K[0-9]{4}-[0-9]{2}-[0-9]{2}' | head -1)
[[ -z "$scheduled" ]] && continue
echo "PR #$pr is scheduled for $scheduled"
if [[ "$scheduled" > "$TODAY" ]]; then
echo " Not yet due, skipping."
continue
fi
author=$(printf '%s' "$pr_json" | jq -r '.author.login')
mentions="@$author"
assignees=$(printf '%s' "$pr_json" | jq -r '.assignees[]?.login')
for a in $assignees; do
[[ "$a" != "$author" ]] && mentions="$mentions @$a"
done
echo " Posting reminder to: $mentions"
gh pr comment "$pr" --repo "$REPO" --body "$mentions — this PR is scheduled to merge on \`$scheduled\`. Please enable auto-merge manually so it goes through the merge queue with CI."
done