Skip to content

Commit c461a34

Browse files
authored
feat: add scheduled merge workflow for blog PRs (#35)
Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
1 parent 50ed5d5 commit c461a34

3 files changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Scheduled Merge
2+
3+
# Enables scheduling a PR merge by adding `/schedule YYYY-MM-DD` to the PR body.
4+
# The PR must already be approved; this workflow only enables auto-merge, which
5+
# then goes through the normal merge queue like any other PR.
6+
#
7+
# Usage: add this line anywhere in the PR description:
8+
# /schedule 2026-05-15
9+
#
10+
# Runs daily at 9–10am Eastern (10am EDT / 9am EST). Use workflow_dispatch to trigger immediately.
11+
12+
on:
13+
schedule:
14+
- cron: '0 14 * * *' # 10am EDT / 9am EST
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
21+
jobs:
22+
merge-scheduled-prs:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Merge scheduled PRs
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
REPO: ${{ github.repository }}
29+
run: |
30+
set -euo pipefail
31+
TODAY=$(TZ='America/New_York' date +%Y-%m-%d)
32+
echo "Today (Eastern): $TODAY"
33+
34+
pr_numbers=$(
35+
gh pr list --repo "$REPO" --state open --json number,body \
36+
--jq '[.[] | select(.body | test("/schedule [0-9]{4}-[0-9]{2}-[0-9]{2}"))] | .[].number'
37+
)
38+
39+
if [[ -z "$pr_numbers" ]]; then
40+
echo "No scheduled PRs found."
41+
exit 0
42+
fi
43+
44+
for pr in $pr_numbers; do
45+
body=$(gh pr view "$pr" --repo "$REPO" --json body --jq '.body')
46+
scheduled=$(printf '%s' "$body" | grep -oP '(?<=/schedule )[0-9]{4}-[0-9]{2}-[0-9]{2}' | head -1)
47+
48+
[[ -z "$scheduled" ]] && continue
49+
50+
echo "PR #$pr is scheduled for $scheduled"
51+
52+
if [[ "$scheduled" > "$TODAY" ]]; then
53+
echo " Not yet due, skipping."
54+
continue
55+
fi
56+
57+
echo " Enabling auto-merge..."
58+
if gh pr merge "$pr" --repo "$REPO" --auto --squash; then
59+
echo " Done."
60+
gh pr comment "$pr" --repo "$REPO" \
61+
--body "Scheduled merge for \`$scheduled\` — added to the merge queue."
62+
else
63+
echo " Warning: could not enable auto-merge."
64+
gh pr comment "$pr" --repo "$REPO" \
65+
--body ":warning: Scheduled merge for \`$scheduled\` could not be enabled. Please check that the PR has the required approvals."
66+
fi
67+
done

AGENTS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ tags: ["tag1", "tag2", "etc"]
143143

144144
Use **US spelling** throughout (`color` not `colour`, `organized` not `organised`). This applies regardless of the author's locale — consistency across posts matters more than author preference.
145145

146+
**Scheduling a publish date** — if you want to delay merging until a specific date, optionally add this line anywhere in the PR description:
147+
148+
```text
149+
/schedule 2026-05-15
150+
```
151+
152+
The PR must be approved before the scheduled date; the workflow runs daily at ~9am Eastern and will add the PR to the merge queue when the date arrives.
153+
146154
Verify with `npm run build` — no config changes or code edits needed.
147155

148156
## 9. Common Issues

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ There are two distinct ways to contribute:
4242
5. Open a PR against `main` on this repository. A member of the
4343
**mellea-maintainers** team must approve the PR before it can be merged.
4444

45+
To delay merging until a specific publish date, optionally add this line anywhere in the PR description:
46+
47+
```text
48+
/schedule 2026-05-15
49+
```
50+
51+
The PR must be approved before the scheduled date. A workflow runs daily at ~9am Eastern and will add the PR to the merge queue automatically when the date arrives.
52+
4553
6. Once merged, the CI pipeline builds and deploys the site automatically —
4654
your post will be live at `mellea.ai/blogs/your-slug` within a few minutes.
4755

0 commit comments

Comments
 (0)