Since workflow_dispatch isn't in the base action, update the examples accordingly

This commit is contained in:
km-anthropic
2025-07-24 10:11:40 -07:00
parent 4a6d3cf183
commit 65bfefd6c4

View File

@@ -1,117 +1,56 @@
name: Claude Code Action Mode Examples name: Claude Mode Examples
on: on:
# Example 1: Tag mode (default) - traditional implementation triggered by mentions # Common events for both modes
issue_comment: issue_comment:
types: [created] types: [created]
issues: issues:
types: [opened, assigned, labeled] types: [opened, labeled]
pull_request: pull_request:
types: [opened, synchronize] types: [opened]
pull_request_review_comment:
types: [created]
pull_request_review:
types: [submitted]
# Example 2: Agent mode - for scheduled tasks and automation
schedule:
- cron: "0 0 * * 1" # Weekly on Monday
workflow_dispatch:
inputs:
task:
description: "Task for Claude to perform"
required: true
type: string
jobs: jobs:
# Example 1: Tag mode (default) - triggered by @claude mentions # Tag Mode (Default) - Traditional implementation
claude-tag-mode: tag-mode-example:
if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: write
pull-requests: write pull-requests: write
issues: write issues: write
id-token: write
steps: steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@main - uses: anthropics/claude-code-action@main
with: with:
# mode defaults to 'tag' - no need to specify
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# Responds to @claude mentions, assignments, and labels # Tag mode (default) behavior:
# Creates tracking comments showing progress # - Scans for @claude mentions in comments, issues, and PRs
# Full implementation capabilities # - Only acts when trigger phrase is found
# - Creates tracking comments with progress checkboxes
# - Perfect for: Interactive Q&A, on-demand code changes
# Example 2: Agent mode - for automation # Agent Mode - Automation without triggers
claude-agent-scheduled: agent-mode-auto-review:
if: github.event_name == 'schedule' # Automatically review every new PR
runs-on: ubuntu-latest if: github.event_name == 'pull_request' && github.event.action == 'opened'
permissions:
contents: write
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@main
with:
mode: agent
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
override_prompt: |
Check the repository for:
1. Outdated dependencies in package.json
2. TODO comments that haven't been addressed
3. Files that haven't been updated in over 6 months
Create an issue summarizing your findings.
# Always runs - no trigger checking
# Perfect for scheduled tasks
# Example 3: Agent mode with workflow_dispatch
claude-agent-dispatch:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@main
with:
mode: agent
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
override_prompt: |
Task: ${{ github.event.inputs.task }}
Repository: $REPOSITORY
Triggered by: $TRIGGER_USERNAME
Please complete the requested task and provide a summary of what was done.
# Example 4: Custom security review with override_prompt
claude-security-review:
if: github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'security-review')
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
pull-requests: write pull-requests: write
issues: write
id-token: write
steps: steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@main - uses: anthropics/claude-code-action@main
with: with:
mode: agent
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
override_prompt: | override_prompt: |
Perform a security review of PR #$PR_NUMBER. Review this PR for code quality. Focus on:
- Potential bugs or logic errors
Focus on: - Security concerns
- SQL injection vulnerabilities - Performance issues
- XSS (Cross-Site Scripting) risks
- Authentication/authorization issues Provide specific, actionable feedback.
- Sensitive data exposure # Agent mode behavior:
- Input validation problems # - NO @claude mention needed - runs immediately
# - Enables true automation (impossible with tag mode)
Changed files: # - Perfect for: CI/CD integration, automatic reviews, label-based workflows
$CHANGED_FILES
Provide severity ratings (Critical/High/Medium/Low) for any issues found.
Be specific about file paths and line numbers.