Skip to content

Commit 4820ffd

Browse files
committed
ci: align Claude workflow with triage-safe triggers and mandatory PR step
- Gate issue_comment on @claude; only claude label triggers label events - Resolve issue/PR number in env; single BRANCH; gh pr create --base/--head - GitHub Actions bot identity, gh auth, GH_TOKEN for gh; MCP issue tools Made-with: Cursor
1 parent 1ff799a commit 4820ffd

File tree

1 file changed

+43
-18
lines changed

1 file changed

+43
-18
lines changed

.github/workflows/claude.yml

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ on:
1212

1313
jobs:
1414
claude-response:
15+
env:
16+
ISSUE_NUMBER_RESOLVED: ${{ github.event.issue.number || github.event.pull_request.number }}
1517
if: |
18+
(github.event.action != 'labeled' || github.event.label.name == 'claude') &&
19+
(github.event_name != 'issue_comment' || contains(github.event.comment.body, '@claude')) &&
1620
(
1721
!contains(github.actor, '[bot]') ||
18-
github.actor == 'github-actions[bot]'
22+
github.actor == 'github-actions[bot]' ||
23+
github.actor == 'praisonai-triage-agent[bot]'
1924
) &&
2025
github.actor != 'dependabot[bot]' &&
26+
github.actor != 'cursor[bot]' &&
2127
github.actor != 'renovate[bot]'
2228
runs-on: ubuntu-latest
2329
permissions:
@@ -32,29 +38,45 @@ jobs:
3238
fetch-depth: 0
3339

3440
- uses: anthropics/claude-code-action@beta
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3543
with:
44+
allowed_bots: 'praisonai-triage-agent[bot]'
3645
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
3746
github_token: ${{ secrets.GITHUB_TOKEN }}
3847
trigger_phrase: "@claude"
3948
label_trigger: "claude"
4049
direct_prompt: |
41-
Analyze this issue and implement a fix:
42-
1. Read the codebase structure and understand tool patterns (see praisonai_tools/tools/lumalabs_tool.py as reference)
43-
2. Implement the tool following existing patterns:
44-
- BaseTool class + standalone @tool functions
45-
- Lazy imports (import requests inside functions)
46-
- Env vars as constructor params (api_key=None, falls back to os.getenv)
47-
- Proper error handling with descriptive messages
48-
- Export in praisonai_tools/tools/__init__.py
49-
3. Run: python -c "import ast; ast.parse(open('praisonai_tools/tools/<new_file>.py').read()); print('OK')"
50-
4. Create a feature branch, commit, push, and create a PR:
51-
git checkout -b feat/<tool-name>
52-
git add .
53-
git commit -m "feat: add <tool-name> tool"
54-
git push origin feat/<tool-name>
55-
gh pr create --title "feat: Add <tool-name> tool" --body "Closes #<issue-number>" --base main
56-
CRITICAL: You MUST create the PR using `gh pr create`. The GITHUB_TOKEN has write permissions.
57-
If `gh pr create` fails, try: GH_TOKEN=$GITHUB_TOKEN gh pr create ...
50+
You are implementing changes in the praisonai-tools repository (Python tools for PraisonAI).
51+
52+
STEP 0 — GIT & GITHUB CLI:
53+
git config --global user.name "github-actions[bot]"
54+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
55+
gh auth setup-git
56+
57+
STEP 1 — ISSUE:
58+
Read the issue/PR context. Scope: implement or fix tools under `praisonai_tools/`.
59+
60+
STEP 2 — IMPLEMENT (tool patterns):
61+
- Use `praisonai_tools/tools/lumalabs_tool.py` as a structural reference where applicable
62+
- BaseTool + `@tool` patterns, lazy imports for optional deps, env via constructor or os.getenv
63+
- Clear errors; export new tools from `praisonai_tools/tools/__init__.py` when adding a tool
64+
- Sanity check: python -c "import ast; ast.parse(open('path/to/file.py').read()); print('OK')"
65+
66+
STEP 3 — BRANCH (one name, reuse in STEP 5):
67+
BRANCH="claude/issue-${{ env.ISSUE_NUMBER_RESOLVED }}-$(date +%Y%m%d)"
68+
git checkout -b "$BRANCH"
69+
70+
STEP 4 — TEST / VERIFY:
71+
Run targeted tests or imports relevant to your edits.
72+
73+
STEP 5 — COMMIT, PUSH, OPEN PR (mandatory if you produced commits):
74+
git add -A
75+
git commit -m "fix: <short summary> (fixes #${{ env.ISSUE_NUMBER_RESOLVED }})"
76+
git push -u origin "$BRANCH"
77+
gh pr create --base main --head "$BRANCH" --title "fix: <short title>" --body "Fixes #${{ env.ISSUE_NUMBER_RESOLVED }}"
78+
Do not stop after push only. Do not ask a human to open the PR. Finish only when `gh pr create` prints a PR URL; on failure, read the error and retry after fixing (auth, duplicate PR, head branch).
79+
5880
allowed_tools: |
5981
Bash(git:*)
6082
Bash(python:*)
@@ -69,4 +91,7 @@ jobs:
6991
BatchTool
7092
Edit
7193
Replace
94+
mcp__github__get_issue
95+
mcp__github__get_issue_comments
96+
mcp__github__update_issue
7297
timeout_minutes: 30

0 commit comments

Comments
 (0)