Skip to content

Commit 817cecf

Browse files
julian-rischclaude
andauthored
ci: fix release branch-off permissions and gate releases on maintainer role (deepset-ai#11485)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 41c2722 commit 817cecf

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

.github/workflows/branch_off.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Branch off
22

33
on:
4-
workflow_dispatch:
54
workflow_call:
65
outputs:
76
bump_version_pr_url:
@@ -24,6 +23,11 @@ jobs:
2423
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2524
with:
2625
ref: main
26+
# Persist the bot token so the branch/tag pushes below authenticate as
27+
# HaystackBot (a ruleset-bypass actor) instead of the default
28+
# github-actions[bot], which only has contents:read and is blocked by
29+
# the release rulesets.
30+
token: ${{ secrets.HAYSTACK_BOT_TOKEN }}
2731

2832
- name: Define all versions
2933
id: versions

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,30 @@ permissions:
1717
contents: read
1818

1919
jobs:
20+
authorize:
21+
# Releasing acts as HaystackBot (a ruleset-bypass actor), so the ruleset
22+
# cannot enforce *who* started the release. Gate on the triggering user's
23+
# role instead: only maintainers/admins may run this workflow, even though
24+
# workflow_dispatch itself is available to anyone with write access.
25+
runs-on: ubuntu-slim
26+
steps:
27+
- name: Verify the triggering user may release
28+
env:
29+
GH_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
30+
ACTOR: ${{ github.triggering_actor }}
31+
run: |
32+
ROLE=$(gh api "repos/${{ github.repository }}/collaborators/${ACTOR}/permission" --jq '.role_name')
33+
echo "::notice::${ACTOR} has repository role '${ROLE}'"
34+
case "$ROLE" in
35+
admin|maintain)
36+
echo "✅ ${ACTOR} is authorized to trigger a release." ;;
37+
*)
38+
echo "::error::${ACTOR} has role '${ROLE}'. A release can only be triggered by a user with the 'maintain' or 'admin' role."
39+
exit 1 ;;
40+
esac
41+
2042
parse-validate-version:
43+
needs: ["authorize"]
2144
runs-on: ubuntu-slim
2245
outputs:
2346
version: ${{ steps.parse-validate.outputs.version }}

0 commit comments

Comments
 (0)