diff --git a/FAQ.md b/FAQ.md index c797fc4..c93c80a 100644 --- a/FAQ.md +++ b/FAQ.md @@ -22,7 +22,7 @@ permissions: 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 diff --git a/MIGRATION.md b/MIGRATION.md index 714a86e..94dc984 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -56,7 +56,7 @@ Now required to explicitly provide a GitHub token: # After (required) - uses: anthropics/claude-code-action@beta with: - github_token: ${{ secrets.GITHUB_TOKEN }} + gitea_token: ${{ secrets.GITHUB_TOKEN }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} ``` @@ -94,7 +94,7 @@ jobs: - name: Run Claude Assistant uses: ./ # Adjust path as needed for your Gitea setup with: - github_token: ${{ secrets.GITHUB_TOKEN }} + gitea_token: ${{ secrets.GITHUB_TOKEN }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} ``` diff --git a/README.md b/README.md index 8a6fac2..c88d6e1 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,7 @@ jobs: - uses: markwylde/claude-code-gitea-action@v1.0.1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - github_token: ${{ secrets.GITEA_TOKEN }} - gitea_api_url: https://gitea.example.com + gitea_token: ${{ secrets.GITEA_TOKEN }} ``` ## Inputs @@ -72,8 +71,7 @@ jobs: | `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 | - | | `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_api_url` | Gitea server URL (e.g., `https://gitea.example.com`) for Gitea installations. Leave empty for GitHub. | No | GitHub API | +| `gitea_token` | Gitea token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - | | `model` | Model to use (provider-specific format required for Bedrock/Vertex) | 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` | @@ -112,8 +110,7 @@ jobs: - uses: anthropics/claude-code-action@beta with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - gitea_api_url: "https://gitea.example.com" - github_token: ${{ secrets.GITEA_TOKEN }} + gitea_token: ${{ secrets.GITEA_TOKEN }} ``` ### Gitea Setup Notes diff --git a/action.yml b/action.yml index 5c1a707..1a0d1a0 100644 --- a/action.yml +++ b/action.yml @@ -44,11 +44,8 @@ inputs: anthropic_api_key: description: "Anthropic API key (required for direct API, not needed for Bedrock/Vertex)" required: false - github_token: - description: "GitHub 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)" + gitea_token: + description: "Gitea token with repo and pull request permissions (defaults to GITHUB_TOKEN)" required: false use_bedrock: description: "Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API" @@ -95,10 +92,10 @@ runs: ALLOWED_TOOLS: ${{ inputs.allowed_tools }} CUSTOM_INSTRUCTIONS: ${{ inputs.custom_instructions }} DIRECT_PROMPT: ${{ inputs.direct_prompt }} - OVERRIDE_GITHUB_TOKEN: ${{ inputs.github_token }} + OVERRIDE_GITHUB_TOKEN: ${{ inputs.gitea_token }} GITHUB_TOKEN: ${{ github.token }} GITHUB_RUN_ID: ${{ github.run_id }} - GITEA_API_URL: ${{ inputs.gitea_api_url }} + GITEA_API_URL: ${{ env.GITHUB_SERVER_URL }} - name: Run Claude Code id: claude-code @@ -129,7 +126,7 @@ runs: # GitHub token for repository access 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) 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 || '' }} PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }} 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 if: steps.prepare.outputs.contains_trigger == 'true' && steps.claude-code.outputs.execution_file != '' diff --git a/examples/claude.yml b/examples/claude.yml index da75416..9b96b78 100644 --- a/examples/claude.yml +++ b/examples/claude.yml @@ -31,6 +31,6 @@ jobs: - name: Run Claude PR Action uses: anthropics/claude-code-action@beta with: - github_token: ${{ secrets.GITHUB_TOKEN }} + gitea_token: ${{ secrets.GITHUB_TOKEN }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} timeout_minutes: "60" diff --git a/examples/gitea-claude.yml b/examples/gitea-claude.yml index e6acf7b..de425b0 100644 --- a/examples/gitea-claude.yml +++ b/examples/gitea-claude.yml @@ -31,7 +31,7 @@ jobs: - name: Run Claude Assistant uses: ./ # Use local action (adjust path as needed) 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 }} timeout_minutes: "60" trigger_phrase: "@claude" diff --git a/src/github/api/config.ts b/src/github/api/config.ts index 4737c1e..9daddae 100644 --- a/src/github/api/config.ts +++ b/src/github/api/config.ts @@ -1,14 +1,14 @@ -export const GITEA_API_URL = - process.env.GITEA_API_URL || "https://api.github.com"; - -// Derive server URL from API URL for Gitea instances -function deriveServerUrl(apiUrl: string): string { - if (apiUrl.includes("api.github.com")) { - return "https://github.com"; +// Derive API URL from server URL for Gitea instances +function deriveApiUrl(serverUrl: string): string { + if (serverUrl.includes("github.com")) { + return "https://api.github.com"; } - // For Gitea, remove /api/v1 from the API URL to get the server URL - return apiUrl.replace(/\/api\/v1\/?$/, ""); + // For Gitea, add /api/v1 to the server URL to get the API URL + return `${serverUrl}/api/v1`; } 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); diff --git a/src/github/token.ts b/src/github/token.ts index a6b1ab0..cedf092 100644 --- a/src/github/token.ts +++ b/src/github/token.ts @@ -23,11 +23,11 @@ export async function setupGitHubToken(): Promise { } 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) { 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); }