Skip to content

Commit 6b48847

Browse files
authored
ci(common): setup git token to clone marketplace in claude action (#1820)
1 parent 9346ba4 commit 6b48847

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

.github/workflows/claude.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ name: claude-review
1111
# Security: Only users with write/admin permissions can trigger Claude.
1212
# External contributors (fork PRs) are automatically blocked by the action.
1313
# See: https://github.com/anthropics/claude-code-action/blob/main/src/github/validation/permissions.ts
14+
#
15+
# Secrets required:
16+
# - CLAUDE_CODE_OAUTH_TOKEN: OAuth token from `claude setup-token`
17+
#
18+
# Note: Private marketplaces require git auth in base-action mode.
19+
# We obtain the Claude GitHub App token and configure git to use it for https clones,
20+
# so the action can clone marketplaces directly.
1421

1522
on:
1623
issue_comment:
@@ -42,6 +49,37 @@ jobs:
4249
- name: Install uv
4350
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b
4451

52+
- name: Get Claude App token
53+
id: claude-token
54+
run: |
55+
# Get OIDC token
56+
OIDC_RESPONSE=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
57+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=claude-code-github-action")
58+
OIDC_TOKEN=$(echo "$OIDC_RESPONSE" | jq -r '.value')
59+
60+
if [ -z "$OIDC_TOKEN" ] || [ "$OIDC_TOKEN" = "null" ]; then
61+
echo "❌ Failed to get OIDC token"
62+
exit 1
63+
fi
64+
65+
# Exchange for GitHub App token
66+
APP_RESPONSE=$(curl -s -X POST https://api.anthropic.com/api/github/github-app-token-exchange \
67+
-H "Authorization: Bearer $OIDC_TOKEN")
68+
APP_TOKEN=$(echo "$APP_RESPONSE" | jq -r '.token // .app_token')
69+
70+
if [ -z "$APP_TOKEN" ] || [ "$APP_TOKEN" = "null" ]; then
71+
echo "❌ Failed to exchange for App token"
72+
exit 1
73+
fi
74+
75+
echo "token=$APP_TOKEN" >> "$GITHUB_OUTPUT"
76+
77+
- name: Configure git for marketplace
78+
run: |
79+
git config --global url."https://x-access-token:${GITHUB_APP_TOKEN}@github.com/".insteadOf "https://github.com/"
80+
env:
81+
GITHUB_APP_TOKEN: ${{ steps.claude-token.outputs.token }}
82+
4583
- name: Run Claude Code
4684
uses: anthropics/claude-code-action@a017b830c03e23789b11fb69ed571ea61c12e45c # 2026-01-16
4785
with:
@@ -50,4 +88,5 @@ jobs:
5088
plugins: |
5189
project-manager@zama-marketplace
5290
zama-developer@zama-marketplace
53-
# Prompt: empty string → action extracts text after @claude automatically
91+
# Prompt: empty string for comments (action extracts text after @claude)
92+
prompt: ""

0 commit comments

Comments
 (0)