Skip to content

Commit 219d61b

Browse files
[chore]: restrict release auto-approval to exact release/vX.Y.Z on main
Address Codex P1: the startsWith(release/v) check alone allowed any release/v-prefixed branch targeting main to be auto-approved, bypassing human review. Now require base==main plus the exact semver release-branch pattern (same as release-workflow.yml), and read branch/PR/repo via env vars to avoid expression injection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 86ffb5a commit 219d61b

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/approve-by-automation.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ permissions:
99

1010
jobs:
1111
approve-release-pr:
12-
if: startsWith(github.head_ref, 'release/v')
12+
if: github.base_ref == 'main' && startsWith(github.head_ref, 'release/v')
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Approve release pull request
1616
env:
1717
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
HEAD_REF: ${{ github.head_ref }}
19+
PR_NUMBER: ${{ github.event.pull_request.number }}
20+
REPO: ${{ github.repository }}
1821
run: |
19-
gh pr review "${{ github.event.pull_request.number }}" \
22+
if ! printf '%s' "$HEAD_REF" | grep -qE '^release/v[0-9]+\.[0-9]+\.[0-9]+$'; then
23+
echo "Not an exact release/vX.Y.Z branch ('$HEAD_REF'); skipping auto-approval."
24+
exit 0
25+
fi
26+
gh pr review "$PR_NUMBER" \
2027
--approve \
21-
--body "Auto-approved: release branch PR. Release is gated by the Jira EM approval." \
22-
--repo "${{ github.repository }}"
28+
--body "Auto-approved: release branch PR (release/vX.Y.Z). Release is gated by the Jira EM approval." \
29+
--repo "$REPO"

0 commit comments

Comments
 (0)