Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 1 addition & 45 deletions .github/workflows/merge-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,4 @@ permissions:

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
uses: generative-computing/.github/.github/workflows/merge-schedule.yml@b8cf2e2d426256f94f9d908e5fc1bcc134b776a1
Loading