Skip to content

Commit 2ff6107

Browse files
committed
verify token perms
1 parent 6bce243 commit 2ff6107

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

.github/workflows/clk-rebase.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,23 @@ jobs:
6060
# with --allowerasing
6161
dnf install curl --allowerasing -y
6262
63-
- name: Verify token permissions
64-
env:
65-
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
63+
- name: Check if token can push
6664
run: |
67-
echo "Verifying token permissions by inspecting API response headers..."
68-
gh api -i /
65+
REPO_PERMS=$(curl -s -H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
66+
-H "Accept: application/vnd.github+json" \
67+
"https://api.github.com/repos/${{ github.repository }}" \
68+
| jq -r '.permissions')
69+
70+
PUSH_ALLOWED=$(echo "$REPO_PERMS" | jq -r '.push')
71+
72+
if [ "$PUSH_ALLOWED" == "true" ]; then
73+
echo "✓ Token has push permissions"
74+
else
75+
echo "✗ Token does NOT have push permissions. Full permissions object: $REPO_PERMS"
76+
exit 1
77+
fi
78+
79+
6980

7081
- name: Checkout kernel-src-tree
7182
uses: actions/checkout@v4

0 commit comments

Comments
 (0)