Skip to content

[GRV-33]: Sync the Human Handoff workspace issue template #49

[GRV-33]: Sync the Human Handoff workspace issue template

[GRV-33]: Sync the Human Handoff workspace issue template #49

Workflow file for this run

# Enable auto-merge (squash) on every newly opened PR.
#
# Uses GITHUB_TOKEN to flip the auto-merge flag — no bot credentials needed
# because enabling auto-merge only sets a repository flag and does not author
# any commit.
name: Set Auto-Merge
on:
pull_request:
types: [opened]
branches: [main]
permissions:
contents: write
pull-requests: write
jobs:
set-automerge:
name: Set auto-merge
runs-on: ubuntu-latest
timeout-minutes: 5
if: ${{ !github.event.pull_request.draft }}
steps:
- name: Enable auto-merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
set -euo pipefail
# Retry loop: GitHub returns "unstable status" if required checks haven't
# registered yet when the PR is first opened. Retrying after a short sleep
# reliably closes that race condition.
for attempt in 1 2 3 4 5; do
already="$(gh pr view "$PR_URL" --json autoMergeRequest --jq '.autoMergeRequest != null')"
if [[ "$already" == "true" ]]; then
echo "Auto-merge already enabled for ${PR_URL}."
exit 0
fi
echo "Enabling auto-merge for ${PR_URL} (attempt ${attempt}/5)."
if gh pr merge --auto --squash "$PR_URL"; then
echo "Auto-merge enabled."
exit 0
fi
if [[ "${attempt}" -lt 5 ]]; then
echo "Attempt ${attempt} failed, retrying in 15s..."
sleep 15
fi
done
echo "Failed to enable auto-merge after 5 attempts."
exit 1