Claude was blocked from writing files, using git/gh, and fetching web content because only a few Bash patterns were pre-approved. Add Edit, Write, WebFetch, git, gh, sed, and python3 to the allowed_tools list. Co-Authored-By: Claude Opus 4.5 <[email protected]>
148 lines
5.4 KiB
YAML
148 lines
5.4 KiB
YAML
name: Claude Code
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
pull_request_review_comment:
|
|
types: [created]
|
|
pull_request_review:
|
|
types: [submitted]
|
|
issues:
|
|
types: [opened, assigned]
|
|
repository_dispatch:
|
|
types: [claude-core-team-issues]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number || github.event.client_payload.issue_number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
claude:
|
|
if: |
|
|
(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' && contains(github.event.review.body, '@claude')) ||
|
|
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
issues: write
|
|
id-token: write
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: postgres
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
- name: Run Claude Code
|
|
uses: anthropics/claude-code-action@v1
|
|
with:
|
|
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
claude_args: "--max-turns 50 --model opus"
|
|
allowed_tools: "Edit,Write,Bash(bash packages/twenty-utils/setup-dev-env.sh),Bash(npx nx *),Bash(npx jest *),Bash(yarn *),Bash(git *),Bash(gh *),Bash(sed *),Bash(python3 *),WebFetch"
|
|
settings: |
|
|
{
|
|
"env": {
|
|
"PG_DATABASE_URL": "postgres://postgres:postgres@localhost:5432/default"
|
|
}
|
|
}
|
|
|
|
claude-cross-repo:
|
|
if: github.event_name == 'repository_dispatch'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
issues: write
|
|
id-token: write
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: postgres
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
- name: Build prompt from dispatch payload
|
|
id: prompt
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const p = context.payload.client_payload;
|
|
let prompt;
|
|
if (p.comment_body) {
|
|
prompt = `You are responding to a comment on issue #${p.issue_number} ("${p.issue_title}") in the ${p.repo_full_name} repository.\n\nThe comment by @${p.sender} says:\n\n${p.comment_body}\n\nIssue body:\n\n${p.issue_body}\n\nPlease help with this request. The code you are working with is the twenty codebase (this repository).`;
|
|
} else {
|
|
prompt = `You are responding to issue #${p.issue_number} ("${p.issue_title}") in the ${p.repo_full_name} repository, opened by @${p.sender}.\n\nIssue body:\n\n${p.issue_body}\n\nPlease help with this request. The code you are working with is the twenty codebase (this repository).`;
|
|
}
|
|
core.setOutput('prompt', prompt);
|
|
core.setOutput('repo', p.repo_full_name);
|
|
core.setOutput('issue_number', p.issue_number);
|
|
- name: Run Claude Code
|
|
id: claude
|
|
uses: anthropics/claude-code-action@v1
|
|
with:
|
|
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
prompt: ${{ steps.prompt.outputs.prompt }}
|
|
claude_args: "--max-turns 50 --model opus"
|
|
allowed_tools: "Edit,Write,Bash(bash packages/twenty-utils/setup-dev-env.sh),Bash(npx nx *),Bash(npx jest *),Bash(yarn *),Bash(git *),Bash(gh *),Bash(sed *),Bash(python3 *),WebFetch"
|
|
settings: |
|
|
{
|
|
"env": {
|
|
"PG_DATABASE_URL": "postgres://postgres:postgres@localhost:5432/default"
|
|
}
|
|
}
|
|
- name: Post response to source issue
|
|
if: always()
|
|
uses: actions/github-script@v7
|
|
with:
|
|
github-token: ${{ secrets.TWENTY_DISPATCH_TOKEN }}
|
|
script: |
|
|
const [owner, repo] = '${{ steps.prompt.outputs.repo }}'.split('/');
|
|
const issueNumber = parseInt('${{ steps.prompt.outputs.issue_number }}', 10);
|
|
|
|
await github.rest.issues.createComment({
|
|
owner,
|
|
repo,
|
|
issue_number: issueNumber,
|
|
body: `Claude finished processing this request. [See workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`
|
|
});
|