feat: add label-triggered Claude job that extracts prompt from issue comments
This commit is contained in:
parent
36d8ec6f09
commit
a8fe178dc6
1 changed files with 49 additions and 9 deletions
58
.github/workflows/claude.yml
vendored
58
.github/workflows/claude.yml
vendored
|
|
@ -11,12 +11,12 @@ on:
|
||||||
types: [submitted]
|
types: [submitted]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# Standard Claude trigger - responds to @claude mentions
|
||||||
claude:
|
claude:
|
||||||
if: |
|
if: |
|
||||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||||
(github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'claude-working') ||
|
|
||||||
(github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'assigned') && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
(github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'assigned') && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
|
@ -39,16 +39,56 @@ jobs:
|
||||||
CRON_SECRET: ${{ secrets.CRON_SECRET }}
|
CRON_SECRET: ${{ secrets.CRON_SECRET }}
|
||||||
with:
|
with:
|
||||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||||
|
|
||||||
# Allow Claude to read CI results and manage issues/PRs
|
|
||||||
additional_permissions: |
|
additional_permissions: |
|
||||||
actions: read
|
actions: read
|
||||||
|
|
||||||
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
|
# Label-triggered Claude - for tool-request pipeline
|
||||||
# prompt: 'Update the pull request description to include a summary of changes.'
|
claude-label-trigger:
|
||||||
|
if: github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'claude-working'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
issues: write
|
||||||
|
id-token: write
|
||||||
|
actions: read
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
# Optional: Add claude_args to customize behavior and configuration
|
- name: Get prompt from issue comments
|
||||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
id: get-prompt
|
||||||
# or https://code.claude.com/docs/en/cli-reference for available options
|
uses: actions/github-script@v7
|
||||||
# claude_args: '--allowed-tools Bash(gh pr:*)'
|
with:
|
||||||
|
script: |
|
||||||
|
const comments = await github.rest.issues.listComments({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
per_page: 100
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find the most recent comment with @claude
|
||||||
|
const claudeComments = comments.data.filter(c => c.body.includes('@claude'));
|
||||||
|
if (claudeComments.length > 0) {
|
||||||
|
const latestComment = claudeComments[claudeComments.length - 1];
|
||||||
|
core.setOutput('prompt', latestComment.body);
|
||||||
|
core.setOutput('found', 'true');
|
||||||
|
} else {
|
||||||
|
core.setOutput('found', 'false');
|
||||||
|
core.setFailed('No @claude comment found in issue');
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Run Claude Code
|
||||||
|
if: steps.get-prompt.outputs.found == 'true'
|
||||||
|
uses: anthropics/claude-code-action@v1
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
CRON_SECRET: ${{ secrets.CRON_SECRET }}
|
||||||
|
with:
|
||||||
|
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||||
|
additional_permissions: |
|
||||||
|
actions: read
|
||||||
|
prompt: ${{ steps.get-prompt.outputs.prompt }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue