forked from SAP/ai-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
29 lines (26 loc) · 854 Bytes
/
auth.yaml
File metadata and controls
29 lines (26 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
name: Check Actor Permission
on:
workflow_dispatch:
workflow_call:
jobs:
check-permission:
name: 'Check if actor has maintain role'
runs-on: ubuntu-latest
steps:
- name: 'Check permission'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTOR: ${{ github.actor }}
REPO: ${{ github.repository }}
run: |
PERMISSION=$(gh api "repos/$REPO/collaborators/$ACTOR/permission" --jq '.permission')
echo "Permission level for $ACTOR: $PERMISSION"
case "$PERMISSION" in
maintain|admin)
echo "Access granted: $ACTOR has '$PERMISSION' permission."
;;
*)
echo "Access denied: $ACTOR has '$PERMISSION' permission, but 'maintain' or higher is required."
exit 1
;;
esac