Skip to content

Commit c7b52fc

Browse files
committed
Check conflicts before benchmark permission is granted
1 parent 7dc7278 commit c7b52fc

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

.github/workflows/pr-commands.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,30 @@ jobs:
8282
PR_NUMBER: ${{ github.event.issue.number }}
8383
REPO: ${{ github.repository }}
8484

85+
# Pre-check that origin/main can auto-merge into the PR. The actual
86+
# merge happens inside benchmark-pr.yml after maintainer approval;
87+
# doing the dry-run here lets us reject conflicting PRs before
88+
# asking a maintainer to approve a run that's guaranteed to abort.
89+
# Skipped for non-save runs since they don't push back.
90+
- name: Check main merges into PR
91+
if: steps.parse.outputs.save == 'true' && steps.parse.outputs.framework != ''
92+
env:
93+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
run: |
95+
git config user.name "github-actions[bot]"
96+
git config user.email "github-actions[bot]@users.noreply.github.com"
97+
git fetch origin main --depth=1
98+
if ! git merge --no-commit --no-ff origin/main; then
99+
git merge --abort 2>/dev/null || true
100+
gh pr comment "${{ steps.parse.outputs.pr }}" \
101+
--repo "${{ github.repository }}" \
102+
--body "⚠️ \`/benchmark --save\` cannot start: \`main\` has diverged and cannot be auto-merged into this branch. Please merge or rebase \`main\` manually, push, and re-run \`/benchmark --save\`."
103+
exit 1
104+
fi
105+
# Discard the merged state — actual merge runs in benchmark-pr.yml
106+
# after maintainer approval. main may move between now and then.
107+
git merge --abort 2>/dev/null || true
108+
85109
- name: React to comment
86110
run: |
87111
gh api "/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" -f content="rocket"

0 commit comments

Comments
 (0)