From 70245e56e330657c561c4315cc1d275d88b8546d Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Mon, 2 Jun 2025 20:52:34 -0700 Subject: [PATCH] feat: add claude_env input for custom environment variables (#102) * feat: add claude_env input for custom environment variables Co-authored-by: ashwin-ant * docs: add claude_env input documentation with clear syntax examples Added comprehensive documentation for the new claude_env input including: - Entry in the Inputs table with description - Example in the basic workflow configuration - Detailed section in Advanced Configuration with practical use cases This makes it clear how users can pass custom environment variables to Claude Code execution in YAML format for CI/test setups. Co-authored-by: ashwin-ant --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: ashwin-ant --- README.md | 22 ++++++++++++++++++++++ action.yml | 3 +++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 3b31ae6..4c4a037 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,11 @@ jobs: # trigger_phrase: "/claude" # Optional: add assignee trigger for issues # assignee_trigger: "claude" + # Optional: add custom environment variables (YAML format) + # claude_env: | + # NODE_ENV: test + # DEBUG: true + # API_URL: https://api.example.com ``` ## Inputs @@ -85,6 +90,7 @@ jobs: | `mcp_config` | Additional MCP configuration (JSON string) that merges with the built-in GitHub MCP servers | No | "" | | `assignee_trigger` | The assignee username that triggers the action (e.g. @claude). Only used for issue assignment | No | - | | `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` | +| `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" | \*Required when using direct Anthropic API (default and when not using Bedrock or Vertex) @@ -289,6 +295,22 @@ This action is built on top of [`anthropics/claude-code-base-action`](https://gi ## Advanced Configuration +### Custom Environment Variables + +You can pass custom environment variables to Claude Code execution using the `claude_env` input. This is useful for CI/test setups that require specific environment variables: + +```yaml +- uses: anthropics/claude-code-action@beta + with: + claude_env: | + NODE_ENV: test + CI: true + DATABASE_URL: postgres://test:test@localhost:5432/test_db + # ... other inputs +``` + +The `claude_env` input accepts YAML format where each line defines a key-value pair. These environment variables will be available to Claude Code during execution, allowing it to run tests, build processes, or other commands that depend on specific environment configurations. + ### Custom Tools By default, Claude only has access to: diff --git a/action.yml b/action.yml index d544f67..a749eeb 100644 --- a/action.yml +++ b/action.yml @@ -41,6 +41,8 @@ inputs: default: "" mcp_config: description: "Additional MCP configuration (JSON string) that merges with the built-in GitHub MCP servers" + claude_env: + description: "Custom environment variables to pass to Claude Code execution (YAML format)" required: false default: "" @@ -114,6 +116,7 @@ runs: use_bedrock: ${{ inputs.use_bedrock }} use_vertex: ${{ inputs.use_vertex }} anthropic_api_key: ${{ inputs.anthropic_api_key }} + claude_env: ${{ inputs.claude_env }} env: # Model configuration ANTHROPIC_MODEL: ${{ inputs.model || inputs.anthropic_model }}