diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index bcba7923..4d8a3be0 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -79,9 +79,26 @@ jobs: with: fetch-depth: 1 + - name: Check Claude authentication + id: claude-auth + env: + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + ANTHROPIC_FEDERATION_RULE_ID: ${{ secrets.ANTHROPIC_FEDERATION_RULE_ID }} + ANTHROPIC_ORGANIZATION_ID: ${{ secrets.ANTHROPIC_ORGANIZATION_ID }} + run: | + if [ -n "$CLAUDE_CODE_OAUTH_TOKEN" ] || + [ -n "$ANTHROPIC_API_KEY" ] || + { [ -n "$ANTHROPIC_FEDERATION_RULE_ID" ] && [ -n "$ANTHROPIC_ORGANIZATION_ID" ]; }; then + echo "available=true" >> "$GITHUB_OUTPUT" + else + echo "available=false" >> "$GITHUB_OUTPUT" + echo "::notice::Skipping Claude Code because no Claude authentication secret is configured." + fi + - name: Run Claude Code id: claude - if: steps.pr_draft.outputs.is_draft != 'true' + if: steps.pr_draft.outputs.is_draft != 'true' && steps.claude-auth.outputs.available == 'true' uses: anthropics/claude-code-action@a92e7c70a4da9793dc164451d829089dc057a464 # v1 with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} diff --git a/templates/workflows/claude.yml b/templates/workflows/claude.yml index ebb5baf2..20ed571a 100644 --- a/templates/workflows/claude.yml +++ b/templates/workflows/claude.yml @@ -94,9 +94,26 @@ jobs: with: fetch-depth: 1 + - name: Check Claude authentication + id: claude-auth + env: + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + ANTHROPIC_FEDERATION_RULE_ID: ${{ secrets.ANTHROPIC_FEDERATION_RULE_ID }} + ANTHROPIC_ORGANIZATION_ID: ${{ secrets.ANTHROPIC_ORGANIZATION_ID }} + run: | + if [ -n "$CLAUDE_CODE_OAUTH_TOKEN" ] || + [ -n "$ANTHROPIC_API_KEY" ] || + { [ -n "$ANTHROPIC_FEDERATION_RULE_ID" ] && [ -n "$ANTHROPIC_ORGANIZATION_ID" ]; }; then + echo "available=true" >> "$GITHUB_OUTPUT" + else + echo "available=false" >> "$GITHUB_OUTPUT" + echo "::notice::Skipping Claude Code because no Claude authentication secret is configured." + fi + - name: Run Claude Code id: claude - if: steps.pr_draft.outputs.is_draft != 'true' + if: steps.pr_draft.outputs.is_draft != 'true' && steps.claude-auth.outputs.available == 'true' uses: anthropics/claude-code-action@a92e7c70a4da9793dc164451d829089dc057a464 # v1 with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}