diff --git a/.github/workflows/merge-schedule.yml b/.github/workflows/merge-schedule.yml new file mode 100644 index 0000000..3071784 --- /dev/null +++ b/.github/workflows/merge-schedule.yml @@ -0,0 +1,67 @@ +name: Scheduled Merge + +# Enables scheduling a PR merge by adding `/schedule YYYY-MM-DD` to the PR body. +# The PR must already be approved; this workflow only enables auto-merge, which +# then goes through the normal merge queue like any other PR. +# +# Usage: add this line anywhere in the PR description: +# /schedule 2026-05-15 +# +# Runs daily at 9–10am Eastern (10am EDT / 9am EST). Use workflow_dispatch to trigger immediately. + +on: + schedule: + - cron: '0 14 * * *' # 10am EDT / 9am EST + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + merge-scheduled-prs: + runs-on: ubuntu-latest + steps: + - name: Merge scheduled 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("/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 + body=$(gh pr view "$pr" --repo "$REPO" --json body --jq '.body') + scheduled=$(printf '%s' "$body" | grep -oP '(?<=/schedule )[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 + + echo " Enabling auto-merge..." + if gh pr merge "$pr" --repo "$REPO" --auto --squash; then + echo " Done." + gh pr comment "$pr" --repo "$REPO" \ + --body "Scheduled merge for \`$scheduled\` — added to the merge queue." + else + echo " Warning: could not enable auto-merge." + gh pr comment "$pr" --repo "$REPO" \ + --body ":warning: Scheduled merge for \`$scheduled\` could not be enabled. Please check that the PR has the required approvals." + fi + done diff --git a/AGENTS.md b/AGENTS.md index b4c7934..6fc664b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -143,6 +143,14 @@ tags: ["tag1", "tag2", "etc"] 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. +**Scheduling a publish date** — if you want to delay merging until a specific date, optionally add this line anywhere in the PR description: + +```text +/schedule 2026-05-15 +``` + +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. + Verify with `npm run build` — no config changes or code edits needed. ## 9. Common Issues diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 916818f..a40ea8c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,6 +42,14 @@ There are two distinct ways to contribute: 5. Open a PR against `main` on this repository. A member of the **mellea-maintainers** team must approve the PR before it can be merged. + To delay merging until a specific publish date, optionally add this line anywhere in the PR description: + + ```text + /schedule 2026-05-15 + ``` + + 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. + 6. Once merged, the CI pipeline builds and deploys the site automatically — your post will be live at `mellea.ai/blogs/your-slug` within a few minutes.