Skip to content

Commit 94b6173

Browse files
committed
Revert REST API approach; add GH_PAT permission diagnostic
The REST API switch was a non-fix: it reuses the same GH_PAT and hits the identical 403 permission check, so it could never resolve the push denial. Reverted ci.yml back to the git-push path. Added a diagnostic step to update-tap.yml that prints the stored secret's actual scopes (x-oauth-scopes), authenticated login, and .permissions on homebrew-heard — so the next run reveals whether the secret can write, rather than us guessing. https://claude.ai/code/session_017hkC9vmFd9ejBQNxzBfcWP
1 parent 7f279f6 commit 94b6173

2 files changed

Lines changed: 32 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,12 @@ jobs:
130130
GH_PAT: ${{ secrets.GH_PAT }}
131131
run: |
132132
VERSION="${{ steps.meta.outputs.version }}"
133-
CONTENT=$(base64 -w 0 Casks/heard.rb)
134-
FILE_SHA=$(curl -sf \
135-
-H "Authorization: token ${GH_PAT}" \
136-
-H "Accept: application/vnd.github+json" \
137-
"https://api.github.com/repos/execsumo/homebrew-heard/contents/Casks/heard.rb" \
138-
| jq -r '.sha')
139-
curl -sf -X PUT \
140-
-H "Authorization: token ${GH_PAT}" \
141-
-H "Accept: application/vnd.github+json" \
142-
"https://api.github.com/repos/execsumo/homebrew-heard/contents/Casks/heard.rb" \
143-
-d "{\"message\":\"Update heard to v${VERSION}\",\"content\":\"${CONTENT}\",\"sha\":\"${FILE_SHA}\"}"
133+
git clone "https://execsumo:${GH_PAT}@github.com/execsumo/homebrew-heard.git" homebrew-tap
134+
mkdir -p homebrew-tap/Casks
135+
cp Casks/heard.rb homebrew-tap/Casks/heard.rb
136+
cd homebrew-tap
137+
git config user.name "github-actions[bot]"
138+
git config user.email "github-actions[bot]@users.noreply.github.com"
139+
git add Casks/heard.rb
140+
git commit -m "Update heard to v${VERSION}"
141+
git push origin HEAD:refs/heads/main

.github/workflows/update-tap.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,31 @@ jobs:
2727
-e "s/sha256 \"[^\"]*\"/sha256 \"${SHA256}\"/" \
2828
Casks/heard.rb
2929
30+
- name: Diagnose GH_PAT permissions
31+
env:
32+
GH_PAT: ${{ secrets.GH_PAT }}
33+
run: |
34+
echo "=== Token scopes (classic PAT) ==="
35+
curl -sI -H "Authorization: token ${GH_PAT}" https://api.github.com/user \
36+
| grep -i '^x-oauth-scopes:' || echo "(no x-oauth-scopes header — fine-grained token or invalid)"
37+
echo "=== Authenticated user ==="
38+
curl -s -H "Authorization: token ${GH_PAT}" https://api.github.com/user | jq -r '.login // "AUTH FAILED"'
39+
echo "=== Write permission on homebrew-heard ==="
40+
curl -s -H "Authorization: token ${GH_PAT}" \
41+
https://api.github.com/repos/execsumo/homebrew-heard | jq '.permissions'
42+
3043
- name: Push cask to Homebrew tap
3144
env:
3245
GH_PAT: ${{ secrets.GH_PAT }}
3346
run: |
3447
VERSION="${{ inputs.version }}"
35-
CONTENT=$(base64 -w 0 Casks/heard.rb)
36-
# Get current file SHA (required by the API to update an existing file)
37-
FILE_SHA=$(curl -sf \
38-
-H "Authorization: token ${GH_PAT}" \
39-
-H "Accept: application/vnd.github+json" \
40-
"https://api.github.com/repos/execsumo/homebrew-heard/contents/Casks/heard.rb" \
41-
| jq -r '.sha')
42-
curl -sf -X PUT \
43-
-H "Authorization: token ${GH_PAT}" \
44-
-H "Accept: application/vnd.github+json" \
45-
"https://api.github.com/repos/execsumo/homebrew-heard/contents/Casks/heard.rb" \
46-
-d "{\"message\":\"Update heard to v${VERSION}\",\"content\":\"${CONTENT}\",\"sha\":\"${FILE_SHA}\"}"
48+
git clone "https://execsumo:${GH_PAT}@github.com/execsumo/homebrew-heard.git" homebrew-tap
49+
mkdir -p homebrew-tap/Casks
50+
cp Casks/heard.rb homebrew-tap/Casks/heard.rb
51+
cd homebrew-tap
52+
git config user.name "github-actions[bot]"
53+
git config user.email "github-actions[bot]@users.noreply.github.com"
54+
git add Casks/heard.rb
55+
git diff --cached --quiet && echo "No changes" && exit 0
56+
git commit -m "Update heard to v${VERSION}"
57+
git push origin HEAD:refs/heads/main

0 commit comments

Comments
 (0)