chore: simplify action config

This commit is contained in:
Mark Wylde
2025-05-31 09:03:12 +01:00
parent fb6df649ed
commit 9714bd59a5
8 changed files with 26 additions and 32 deletions

2
FAQ.md
View File

@@ -22,7 +22,7 @@ permissions:
id-token: write # Required for OIDC authentication id-token: write # Required for OIDC authentication
``` ```
The OIDC token is required in order for the Claude GitHub app to function. If you wish to not use the GitHub app, you can instead provide a `github_token` input to the action for Claude to operate with. See the [Claude Code permissions documentation][perms] for more. The OIDC token is required in order for the Claude GitHub app to function. If you wish to not use the GitHub app, you can instead provide a `gitea_token` input to the action for Claude to operate with. See the [Claude Code permissions documentation][perms] for more.
## Claude's Capabilities and Limitations ## Claude's Capabilities and Limitations

View File

@@ -56,7 +56,7 @@ Now required to explicitly provide a GitHub token:
# After (required) # After (required)
- uses: anthropics/claude-code-action@beta - uses: anthropics/claude-code-action@beta
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} gitea_token: ${{ secrets.GITHUB_TOKEN }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
``` ```
@@ -94,7 +94,7 @@ jobs:
- name: Run Claude Assistant - name: Run Claude Assistant
uses: ./ # Adjust path as needed for your Gitea setup uses: ./ # Adjust path as needed for your Gitea setup
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} gitea_token: ${{ secrets.GITHUB_TOKEN }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
``` ```

View File

@@ -61,8 +61,7 @@ jobs:
- uses: markwylde/claude-code-gitea-action@v1.0.1 - uses: markwylde/claude-code-gitea-action@v1.0.1
with: with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITEA_TOKEN }} gitea_token: ${{ secrets.GITEA_TOKEN }}
gitea_api_url: https://gitea.example.com
``` ```
## Inputs ## Inputs
@@ -72,8 +71,7 @@ jobs:
| `anthropic_api_key` | Anthropic API key (required for direct API, not needed for Bedrock/Vertex) | No\* | - | | `anthropic_api_key` | Anthropic API key (required for direct API, not needed for Bedrock/Vertex) | No\* | - |
| `direct_prompt` | Direct prompt for Claude to execute automatically without needing a trigger (for automated workflows) | No | - | | `direct_prompt` | Direct prompt for Claude to execute automatically without needing a trigger (for automated workflows) | No | - |
| `timeout_minutes` | Timeout in minutes for execution | No | `30` | | `timeout_minutes` | Timeout in minutes for execution | No | `30` |
| `github_token` | GitHub token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - | | `gitea_token` | Gitea token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - |
| `gitea_api_url` | Gitea server URL (e.g., `https://gitea.example.com`) for Gitea installations. Leave empty for GitHub. | No | GitHub API |
| `model` | Model to use (provider-specific format required for Bedrock/Vertex) | No | - | | `model` | Model to use (provider-specific format required for Bedrock/Vertex) | No | - |
| `anthropic_model` | **DEPRECATED**: Use `model` instead. Kept for backward compatibility. | No | - | | `anthropic_model` | **DEPRECATED**: Use `model` instead. Kept for backward compatibility. | No | - |
| `use_bedrock` | Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API | No | `false` | | `use_bedrock` | Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API | No | `false` |
@@ -112,8 +110,7 @@ jobs:
- uses: anthropics/claude-code-action@beta - uses: anthropics/claude-code-action@beta
with: with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
gitea_api_url: "https://gitea.example.com" gitea_token: ${{ secrets.GITEA_TOKEN }}
github_token: ${{ secrets.GITEA_TOKEN }}
``` ```
### Gitea Setup Notes ### Gitea Setup Notes

View File

@@ -44,11 +44,8 @@ inputs:
anthropic_api_key: anthropic_api_key:
description: "Anthropic API key (required for direct API, not needed for Bedrock/Vertex)" description: "Anthropic API key (required for direct API, not needed for Bedrock/Vertex)"
required: false required: false
github_token: gitea_token:
description: "GitHub token with repo and pull request permissions (defaults to GITHUB_TOKEN)" description: "Gitea token with repo and pull request permissions (defaults to GITHUB_TOKEN)"
required: false
gitea_api_url:
description: "Gitea server URL (e.g., https://gitea.example.com, defaults to GitHub API)"
required: false required: false
use_bedrock: use_bedrock:
description: "Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API" description: "Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API"
@@ -95,10 +92,10 @@ runs:
ALLOWED_TOOLS: ${{ inputs.allowed_tools }} ALLOWED_TOOLS: ${{ inputs.allowed_tools }}
CUSTOM_INSTRUCTIONS: ${{ inputs.custom_instructions }} CUSTOM_INSTRUCTIONS: ${{ inputs.custom_instructions }}
DIRECT_PROMPT: ${{ inputs.direct_prompt }} DIRECT_PROMPT: ${{ inputs.direct_prompt }}
OVERRIDE_GITHUB_TOKEN: ${{ inputs.github_token }} OVERRIDE_GITHUB_TOKEN: ${{ inputs.gitea_token }}
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}
GITHUB_RUN_ID: ${{ github.run_id }} GITHUB_RUN_ID: ${{ github.run_id }}
GITEA_API_URL: ${{ inputs.gitea_api_url }} GITEA_API_URL: ${{ env.GITHUB_SERVER_URL }}
- name: Run Claude Code - name: Run Claude Code
id: claude-code id: claude-code
@@ -129,7 +126,7 @@ runs:
# GitHub token for repository access # GitHub token for repository access
GITHUB_TOKEN: ${{ steps.prepare.outputs.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ steps.prepare.outputs.GITHUB_TOKEN }}
GITEA_API_URL: ${{ inputs.gitea_api_url }} GITEA_API_URL: ${{ env.GITHUB_SERVER_URL }}
# Provider configuration (for future cloud provider support) # Provider configuration (for future cloud provider support)
ANTHROPIC_BASE_URL: ${{ env.ANTHROPIC_BASE_URL }} ANTHROPIC_BASE_URL: ${{ env.ANTHROPIC_BASE_URL }}
@@ -167,7 +164,7 @@ runs:
TRIGGER_USERNAME: ${{ github.event.comment.user.login || github.event.issue.user.login || github.event.pull_request.user.login || github.event.sender.login || github.triggering_actor || github.actor || '' }} TRIGGER_USERNAME: ${{ github.event.comment.user.login || github.event.issue.user.login || github.event.pull_request.user.login || github.event.sender.login || github.triggering_actor || github.actor || '' }}
PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }} PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }}
PREPARE_ERROR: ${{ steps.prepare.outputs.prepare_error || '' }} PREPARE_ERROR: ${{ steps.prepare.outputs.prepare_error || '' }}
GITEA_API_URL: ${{ inputs.gitea_api_url }} GITEA_API_URL: ${{ env.GITHUB_SERVER_URL }}
- name: Display Claude Code Report - name: Display Claude Code Report
if: steps.prepare.outputs.contains_trigger == 'true' && steps.claude-code.outputs.execution_file != '' if: steps.prepare.outputs.contains_trigger == 'true' && steps.claude-code.outputs.execution_file != ''

View File

@@ -31,6 +31,6 @@ jobs:
- name: Run Claude PR Action - name: Run Claude PR Action
uses: anthropics/claude-code-action@beta uses: anthropics/claude-code-action@beta
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} gitea_token: ${{ secrets.GITHUB_TOKEN }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
timeout_minutes: "60" timeout_minutes: "60"

View File

@@ -31,7 +31,7 @@ jobs:
- name: Run Claude Assistant - name: Run Claude Assistant
uses: ./ # Use local action (adjust path as needed) uses: ./ # Use local action (adjust path as needed)
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} # Use standard workflow token gitea_token: ${{ secrets.GITHUB_TOKEN }} # Use standard workflow token
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
timeout_minutes: "60" timeout_minutes: "60"
trigger_phrase: "@claude" trigger_phrase: "@claude"

View File

@@ -1,14 +1,14 @@
export const GITEA_API_URL = // Derive API URL from server URL for Gitea instances
process.env.GITEA_API_URL || "https://api.github.com"; function deriveApiUrl(serverUrl: string): string {
if (serverUrl.includes("github.com")) {
// Derive server URL from API URL for Gitea instances return "https://api.github.com";
function deriveServerUrl(apiUrl: string): string {
if (apiUrl.includes("api.github.com")) {
return "https://github.com";
} }
// For Gitea, remove /api/v1 from the API URL to get the server URL // For Gitea, add /api/v1 to the server URL to get the API URL
return apiUrl.replace(/\/api\/v1\/?$/, ""); return `${serverUrl}/api/v1`;
} }
export const GITEA_SERVER_URL = export const GITEA_SERVER_URL =
process.env.GITEA_SERVER_URL || deriveServerUrl(GITEA_API_URL); process.env.GITHUB_SERVER_URL || "https://github.com";
export const GITEA_API_URL =
process.env.GITEA_API_URL || deriveApiUrl(GITEA_SERVER_URL);

View File

@@ -23,11 +23,11 @@ export async function setupGitHubToken(): Promise<string> {
} }
throw new Error( throw new Error(
"No GitHub token available. Please provide a github_token input or ensure GITHUB_TOKEN is available in the workflow environment.", "No GitHub token available. Please provide a gitea_token input or ensure GITHUB_TOKEN is available in the workflow environment.",
); );
} catch (error) { } catch (error) {
core.setFailed( core.setFailed(
`Failed to setup GitHub token: ${error}.\n\nPlease provide a \`github_token\` in the \`with\` section of the action in your workflow yml file, or ensure the workflow has access to the default GITHUB_TOKEN.`, `Failed to setup GitHub token: ${error}.\n\nPlease provide a \`gitea_token\` in the \`with\` section of the action in your workflow yml file, or ensure the workflow has access to the default GITHUB_TOKEN.`,
); );
process.exit(1); process.exit(1);
} }