mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
feat: add settings input support (#276)
- Add settings input to action.yml that accepts JSON string or file path - Pass settings parameter to claude-code-base-action - Update README with comprehensive settings documentation - Add link to official Claude Code settings documentation - Document precedence rules for model and tool permissions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
60
README.md
60
README.md
@@ -189,6 +189,7 @@ jobs:
|
|||||||
| `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` |
|
| `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` |
|
||||||
| `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` |
|
| `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` |
|
||||||
| `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" |
|
| `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" |
|
||||||
|
| `settings` | Claude Code settings as JSON string or path to settings JSON file | No | "" |
|
||||||
| `additional_permissions` | Additional permissions to enable. Currently supports 'actions: read' for viewing workflow results | No | "" |
|
| `additional_permissions` | Additional permissions to enable. Currently supports 'actions: read' for viewing workflow results | No | "" |
|
||||||
|
|
||||||
\*Required when using direct Anthropic API (default and when not using Bedrock or Vertex)
|
\*Required when using direct Anthropic API (default and when not using Bedrock or Vertex)
|
||||||
@@ -571,6 +572,65 @@ Use a specific Claude model:
|
|||||||
# ... other inputs
|
# ... other inputs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Claude Code Settings
|
||||||
|
|
||||||
|
You can provide Claude Code settings to customize behavior such as model selection, environment variables, permissions, and hooks. Settings can be provided either as a JSON string or a path to a settings file.
|
||||||
|
|
||||||
|
#### Option 1: Settings File
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: anthropics/claude-code-action@beta
|
||||||
|
with:
|
||||||
|
settings: "path/to/settings.json"
|
||||||
|
# ... other inputs
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Option 2: Inline Settings
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: anthropics/claude-code-action@beta
|
||||||
|
with:
|
||||||
|
settings: |
|
||||||
|
{
|
||||||
|
"model": "claude-opus-4-20250514",
|
||||||
|
"env": {
|
||||||
|
"DEBUG": "true",
|
||||||
|
"API_URL": "https://api.example.com"
|
||||||
|
},
|
||||||
|
"permissions": {
|
||||||
|
"allow": ["Bash", "Read"],
|
||||||
|
"deny": ["WebFetch"]
|
||||||
|
},
|
||||||
|
"hooks": {
|
||||||
|
"PreToolUse": [{
|
||||||
|
"matcher": "Bash",
|
||||||
|
"hooks": [{
|
||||||
|
"type": "command",
|
||||||
|
"command": "echo Running bash command..."
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# ... other inputs
|
||||||
|
```
|
||||||
|
|
||||||
|
The settings support all Claude Code settings options including:
|
||||||
|
|
||||||
|
- `model`: Override the default model
|
||||||
|
- `env`: Environment variables for the session
|
||||||
|
- `permissions`: Tool usage permissions
|
||||||
|
- `hooks`: Pre/post tool execution hooks
|
||||||
|
- And more...
|
||||||
|
|
||||||
|
For a complete list of available settings and their descriptions, see the [Claude Code settings documentation](https://docs.anthropic.com/en/docs/claude-code/settings).
|
||||||
|
|
||||||
|
**Notes**:
|
||||||
|
|
||||||
|
- The `enableAllProjectMcpServers` setting is always set to `true` by this action to ensure MCP servers work correctly.
|
||||||
|
- If both the `model` input parameter and a `model` in settings are provided, the `model` input parameter takes precedence.
|
||||||
|
- The `allowed_tools` and `disallowed_tools` input parameters take precedence over `permissions` in settings.
|
||||||
|
- In a future version, we may deprecate individual input parameters in favor of using the settings file for all configuration.
|
||||||
|
|
||||||
## Cloud Providers
|
## Cloud Providers
|
||||||
|
|
||||||
You can authenticate with Claude using any of these three methods:
|
You can authenticate with Claude using any of these three methods:
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ inputs:
|
|||||||
description: "Custom environment variables to pass to Claude Code execution (YAML format)"
|
description: "Custom environment variables to pass to Claude Code execution (YAML format)"
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
settings:
|
||||||
|
description: "Claude Code settings as JSON string or path to settings JSON file"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
# Auth configuration
|
# Auth configuration
|
||||||
anthropic_api_key:
|
anthropic_api_key:
|
||||||
@@ -160,6 +164,7 @@ runs:
|
|||||||
anthropic_api_key: ${{ inputs.anthropic_api_key }}
|
anthropic_api_key: ${{ inputs.anthropic_api_key }}
|
||||||
claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }}
|
claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }}
|
||||||
claude_env: ${{ inputs.claude_env }}
|
claude_env: ${{ inputs.claude_env }}
|
||||||
|
settings: ${{ inputs.settings }}
|
||||||
env:
|
env:
|
||||||
# Model configuration
|
# Model configuration
|
||||||
ANTHROPIC_MODEL: ${{ inputs.model || inputs.anthropic_model }}
|
ANTHROPIC_MODEL: ${{ inputs.model || inputs.anthropic_model }}
|
||||||
|
|||||||
Reference in New Issue
Block a user