mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
docs: update structured output documentation for JSON-only approach
Updated documentation to reflect that structured outputs are now only
accessible via the single structured_output JSON string, not as
individual fields.
Changes:
- docs/usage.md: Updated "Accessing Structured Outputs" section
- Show fromJSON() usage in GitHub Actions expressions
- Show jq usage in bash
- Explain composite action limitation
- Remove outdated "Output Naming Rules" and size limit sections
- action.yml: Updated json_schema input description
- examples/test-failure-analysis.yml: Updated to use fromJSON() and jq
Users now access fields via:
fromJSON(steps.<id>.outputs.structured_output).field_name
Or:
echo '${{ steps.<id>.outputs.structured_output }}' | jq '.field_name'
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -213,7 +213,7 @@ Get validated JSON results from Claude that automatically become GitHub Action o
|
||||
}
|
||||
|
||||
- name: Retry if flaky
|
||||
if: steps.analyze.outputs.is_flaky == 'true'
|
||||
if: fromJSON(steps.analyze.outputs.structured_output).is_flaky == true
|
||||
run: gh workflow run CI
|
||||
```
|
||||
|
||||
@@ -222,29 +222,31 @@ Get validated JSON results from Claude that automatically become GitHub Action o
|
||||
1. **Define Schema**: Provide a JSON schema in the `json_schema` input
|
||||
2. **Claude Executes**: Claude uses tools to complete your task
|
||||
3. **Validated Output**: Result is validated against your schema
|
||||
4. **Auto-set Outputs**: Each field automatically becomes a GitHub Action output
|
||||
4. **JSON Output**: All fields are returned in a single `structured_output` JSON string
|
||||
|
||||
### Type Conversions
|
||||
### Accessing Structured Outputs
|
||||
|
||||
GitHub Actions outputs must be strings. Values are converted automatically:
|
||||
All structured output fields are available in the `structured_output` output as a JSON string:
|
||||
|
||||
- `boolean` → `"true"` or `"false"`
|
||||
- `number` → `"42"` or `"3.14"`
|
||||
- `object/array` → JSON stringified (use `fromJSON()` in workflows to parse)
|
||||
- `null` → `""` (empty string)
|
||||
**In GitHub Actions expressions:**
|
||||
|
||||
### Output Naming Rules
|
||||
```yaml
|
||||
if: fromJSON(steps.analyze.outputs.structured_output).is_flaky == true
|
||||
run: |
|
||||
CONFIDENCE=${{ fromJSON(steps.analyze.outputs.structured_output).confidence }}
|
||||
```
|
||||
|
||||
- Field names are sanitized: special characters replaced with underscores
|
||||
- Must start with letter or underscore (GitHub Actions requirement)
|
||||
- Reserved names (`conclusion`, `execution_file`) are automatically skipped
|
||||
- Example: `test.result` becomes `test_result`
|
||||
**In bash with jq:**
|
||||
|
||||
### Size Limits
|
||||
```yaml
|
||||
- name: Process results
|
||||
run: |
|
||||
OUTPUT='${{ steps.analyze.outputs.structured_output }}'
|
||||
IS_FLAKY=$(echo "$OUTPUT" | jq -r '.is_flaky')
|
||||
SUMMARY=$(echo "$OUTPUT" | jq -r '.summary')
|
||||
```
|
||||
|
||||
- Maximum 1MB per output field
|
||||
- Objects/arrays exceeding 1MB are skipped with warnings
|
||||
- Primitive values exceeding 1MB are truncated
|
||||
**Note**: Due to GitHub Actions limitations, composite actions cannot expose dynamic outputs. All fields are bundled in the single `structured_output` JSON string.
|
||||
|
||||
### Complete Example
|
||||
|
||||
|
||||
Reference in New Issue
Block a user