Skip to content

Commit 7f191d3

Browse files
committed
ci: temporary GH_TOKEN scope verification (revert before merge)
1 parent d7a796b commit 7f191d3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "TEMP: verify GH_TOKEN scope (will be removed before merge)"
2+
permissions: {}
3+
"on":
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check GH_TOKEN push access to this repo
13+
env:
14+
T: ${{ secrets.GH_TOKEN }}
15+
run: |
16+
set -euo pipefail
17+
if [ -z "$T" ]; then
18+
echo "RESULT: GH_TOKEN secret is empty or not available"
19+
exit 1
20+
fi
21+
# Print only booleans/derived facts, never the token or account details.
22+
RESP=$(curl -s -H "Authorization: token $T" https://api.github.com/repos/${{ github.repository }})
23+
echo "RESULT: can_push=$(echo "$RESP" | jq -r '.permissions.push // false')"
24+
echo "RESULT: can_admin=$(echo "$RESP" | jq -r '.permissions.admin // false')"
25+
SCOPES=$(curl -sI -H "Authorization: token $T" https://api.github.com/user | grep -i '^x-oauth-scopes:' | cut -d: -f2- | tr -d ' \r')
26+
if echo ",$SCOPES," | grep -q ',repo,'; then
27+
echo "RESULT: has_repo_scope=true"
28+
else
29+
echo "RESULT: has_repo_scope=false (classic scopes: present-but-redacted-count=$(echo "$SCOPES" | awk -F, '{print NF}'))"
30+
fi

0 commit comments

Comments
 (0)