Skip to content

[BUG] θΏ™δΈͺεŠŸθƒ½ζœ‰ζŠ₯ι”™ #35

[BUG] θΏ™δΈͺεŠŸθƒ½ζœ‰ζŠ₯ι”™

[BUG] θΏ™δΈͺεŠŸθƒ½ζœ‰ζŠ₯ι”™ #35

Workflow file for this run

# Copyright 2024-2026 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Claude Assistant
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned, labeled]
pull_request_review:
types: [submitted]
env:
ANTHROPIC_BASE_URL: "https://open.bigmodel.cn/api/anthropic"
jobs:
claude-response:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Assistant
id: claude_assistant
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# Or use OAuth token instead:
# claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
# Optional: provide a prompt for automation workflows
# prompt: "Review this PR for security issues"
# Optional: pass advanced arguments to Claude CLI
# claude_args: |
# --max-turns 10
# --model claude-4-0-sonnet-20250805
# Optional: add custom trigger phrase (default: @claude)
# trigger_phrase: "/claude"
# Optional: add assignee trigger for issues
# assignee_trigger: "claude"
# Optional: add label trigger for issues
# label_trigger: "claude"
# Optional: grant additional permissions (requires corresponding GitHub token permissions)
# additional_permissions: |
# actions: read
# Optional: allow bot users to trigger the action
# allowed_bots: "dependabot[bot],renovate[bot]"
- name: Post Claude assistant summary
if: always() && (github.event_name == 'issues' || github.event_name == 'issue_comment')
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
// Get issue number from different event types
let issue_number;
if (context.eventName === 'issues') {
issue_number = context.issue.number;
} else if (context.eventName === 'issue_comment') {
issue_number = context.payload.issue.number;
} else {
console.log('Event type not supported for issue comments');
return;
}
// Get Claude's response
const stepOutputs = ${{ toJson(steps.claude_assistant.outputs) }};
const claudeResponse = stepOutputs.response || stepOutputs.result || stepOutputs.output || '';
// Get workflow run URL
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${{ github.run_id }}`;
let commentBody = `## πŸ€– Claude Assistant Summary\n\n`;
if (claudeResponse && claudeResponse.trim() !== '') {
commentBody += `**Claude Response:**\n\`\`\`\n${claudeResponse}\n\`\`\`\n\n`;
} else {
commentBody += `**Status:** Claude assistant completed processing.\n\n`;
}
commentBody += `**Workflow Run:** [View Details](${runUrl})\n`;
commentBody += `**Triggered by:** ${context.eventName}\n`;
commentBody += `**Time:** ${new Date().toISOString()}\n\n`;
commentBody += `---\n*This comment was automatically generated by the Claude Assistant workflow.*`;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: commentBody
});
console.log('Posted Claude assistant summary to issue #' + issue_number);