Skip to content

Commit a960a3e

Browse files
authored
Merge pull request #14 from ai4curation/allow-oauth
allow oauth
2 parents 388f1dd + ed32d1f commit a960a3e

19 files changed

Lines changed: 181 additions & 96 deletions

File tree

.claude/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(*)",
5+
"Edit",
6+
"MultiEdit",
7+
"NotebookEdit",
8+
"FileEdit",
9+
"WebFetch",
10+
"WebSearch",
11+
"Write"
12+
]
13+
}
14+
}

.github/actions/claude-code-action/action.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ inputs:
77
required: true
88
anthropic_api_key:
99
description: "Anthropic API key"
10-
required: true
10+
required: false
1111
cborg_api_key:
1212
description: "CBORG API key"
13-
required: true
13+
required: false
14+
claude_code_oauth_token:
15+
description: "Claude Code OAuth token"
16+
required: false
1417
prompt:
1518
description: "The prompt to send to Claude Code"
1619
required: false
@@ -90,6 +93,7 @@ runs:
9093
shell: bash
9194
id: prepare_prompt
9295
run: |
96+
9397
# Check if either prompt or prompt_file is provided
9498
if [ -z "${{ inputs.prompt }}" ] && [ -z "${{ inputs.prompt_file }}" ]; then
9599
echo "::error::Neither 'prompt' nor 'prompt_file' was provided. At least one is required."
@@ -125,6 +129,14 @@ runs:
125129
shell: bash
126130
id: run_claude
127131
run: |
132+
133+
if [ ! -z "${{ inputs.claude_code_oauth_token }}" ]; then
134+
echo CLAUDE AUTH TOKEN IS NOT SET
135+
else
136+
echo CLAUDE AUTH TOKEN IS SET
137+
export ANTHROPIC_API_KEY=
138+
fi
139+
128140
ALLOWED_TOOLS_ARG=""
129141
if [ ! -z "${{ inputs.allowed_tools }}" ]; then
130142
ALLOWED_TOOLS_ARG="--allowedTools ${{ inputs.allowed_tools }}"
@@ -135,15 +147,15 @@ runs:
135147
136148
if [ -z "${{ inputs.output_file }}" ]; then
137149
# Run Claude Code and output to console
138-
timeout $timeout_seconds claude \
150+
claude \
139151
-p \
140152
--verbose \
141153
--output-format stream-json \
142154
"$(cat ${{ env.PROMPT_PATH }})" \
143155
${{ inputs.allowed_tools != '' && format('--allowedTools "{0}"', inputs.allowed_tools) || '' }}
144156
else
145157
# Run Claude Code and tee output to console and file
146-
timeout $timeout_seconds claude \
158+
claude \
147159
-p \
148160
--verbose \
149161
--output-format stream-json \
@@ -160,8 +172,9 @@ runs:
160172
fi
161173
162174
env:
163-
ANTHROPIC_API_KEY: "."
164-
ANTHROPIC_AUTH_TOKEN: ${{ inputs.cborg_api_key }}
175+
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
176+
# ANTHROPIC_AUTH_TOKEN: ${{ inputs.cborg_api_key }}
177+
CLAUDE_CODE_OAUTH_TOKEN: ${{ inputs.claude_code_oauth_token }}
165178
GITHUB_TOKEN: ${{ inputs.github_token }}
166-
ANTHROPIC_BASE_URL: "https://api.cborg.lbl.gov"
167-
DISABLE_NON_ESSENTIAL_MODEL_CALLS: "1"
179+
# ANTHROPIC_BASE_URL: "https://api.cborg.lbl.gov"
180+
# DISABLE_NON_ESSENTIAL_MODEL_CALLS: "1"

.github/actions/claude-issue-summarize-action/action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ inputs:
88
default: "5"
99
anthropic_api_key:
1010
description: "Anthropic API key"
11-
required: true
11+
required: false
1212
cborg_api_key:
1313
description: "CBORG API key"
14-
required: true
14+
required: false
15+
claude_code_oauth_token:
16+
description: "Claude Code OAuth token"
17+
required: false
1518
github_token:
1619
description: "GitHub token with repo and issues permissions"
1720
required: true
@@ -22,7 +25,7 @@ runs:
2225
- name: Checkout repository code
2326
uses: actions/checkout@v4
2427
with:
25-
fetch-depth: 0
28+
ref: ${{ github.ref }}
2629

2730
- name: Create prompt file
2831
shell: bash
@@ -70,5 +73,6 @@ runs:
7073
install_artl_mcp: "true"
7174
timeout_minutes: ${{ inputs.timeout_minutes }}
7275
anthropic_api_key: ${{ inputs.anthropic_api_key }}
76+
claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }}
7377
cborg_api_key: ${{ inputs.cborg_api_key }}
7478
github_token: ${{ inputs.github_token }}

.github/actions/claude-issue-triage-action/action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ inputs:
88
default: "5"
99
anthropic_api_key:
1010
description: "Anthropic API key"
11-
required: true
11+
required: false
12+
claude_code_oauth_token:
13+
description: "Claude Code OAuth token"
14+
required: false
1215
cborg_api_key:
1316
description: "CBORG API key"
1417
required: true
@@ -22,7 +25,7 @@ runs:
2225
- name: Checkout repository code
2326
uses: actions/checkout@v4
2427
with:
25-
fetch-depth: 0
28+
ref: ${{ github.ref }}
2629

2730
- name: Create prompt file
2831
shell: bash
@@ -87,5 +90,6 @@ runs:
8790
install_github_mcp: "true"
8891
timeout_minutes: ${{ inputs.timeout_minutes }}
8992
anthropic_api_key: ${{ inputs.anthropic_api_key }}
93+
claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }}
9094
cborg_api_key: ${{ inputs.cborg_api_key }}
9195
github_token: ${{ inputs.github_token }}

.github/workflows/claude-code-review.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
with:
3838
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
3939

40-
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1)
41-
# model: "claude-opus-4-1-20250805"
42-
40+
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
41+
# model: "claude-opus-4-20250514"
42+
4343
# Direct prompt for automated review (no @claude mention needed)
4444
direct_prompt: |
4545
Please review this pull request and provide feedback on:

.github/workflows/claude-issue-summarize.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ jobs:
1515
steps:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
18+
with:
19+
ref: ${{ github.ref }}
1820

1921
- name: Run Claude Issue summarize
2022
uses: ./.github/actions/claude-issue-summarize-action
2123
with:
2224
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
25+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
2326
cborg_api_key: ${{ secrets.CBORG_API_KEY }}
2427
github_token: ${{ secrets.GITHUB_TOKEN }}
25-
install_artl_mcp: "true"

.github/workflows/claude-issue-triage.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ jobs:
1515
steps:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
18-
18+
with:
19+
ref: ${{ github.ref }}
20+
1921
- name: Run Claude Issue Triage
2022
uses: ./.github/actions/claude-issue-triage-action
2123
with:
2224
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
25+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
2326
cborg_api_key: ${{ secrets.CBORG_API_KEY }}
2427
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/dragon-ai.yml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ jobs:
2121
result: ${{ steps.check.outputs.result }}
2222
steps:
2323
- name: Checkout repository
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
25+
# this seems to be necessary to ensure actions uses the latest; see
26+
# https://github.com/actions/checkout/issues/439
27+
with:
28+
ref: ${{ github.ref }}
2529

2630
- name: Check for qualifying mention
2731
id: check
@@ -97,9 +101,9 @@ jobs:
97101
runs-on: ubuntu-latest
98102
steps:
99103
- name: Checkout repository
100-
uses: actions/checkout@v3
104+
uses: actions/checkout@v4
101105
with:
102-
fetch-depth: 0
106+
ref: ${{ github.ref }}
103107
token: ${{ secrets.PAT_FOR_PR }} # Use PAT for checkout to allow committing later
104108

105109
- name: Configure Git
@@ -119,22 +123,12 @@ jobs:
119123
run: |
120124
npm install -g @anthropic-ai/claude-code
121125
122-
123-
- name: Set up environment
124-
run: |
125-
echo "BRANCH_NAME=dragon_ai_agent_${{ fromJSON(needs.check-mention.outputs.result).itemNumber }}" >> $GITHUB_ENV
126-
# Safely write prompt to file
127-
mkdir -p /tmp/claude-input
128-
echo "${{ fromJSON(needs.check-mention.outputs.result).prompt }}" > /tmp/claude-input/prompt.txt
129-
130-
- name: Set up Anthropic API key and GitHub token
131-
env:
132-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
133-
GH_TOKEN: ${{ secrets.PAT_FOR_PR }} # Kept PAT as requested
126+
127+
- name: Add tools to PATH
134128
run: |
135-
echo "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" >> $GITHUB_ENV
136-
echo "GH_TOKEN=$GH_TOKEN" >> $GITHUB_ENV
137-
echo "LOGFIRE_SEND_TO_LOGFIRE=false" >> $GITHUB_ENV
129+
echo "${{ env.TOOLS_DIR }}" >> $GITHUB_PATH
130+
ls -alt ${{ github.workspace }}
131+
ls -alt ${{ env.TOOLS_DIR }}
138132
139133
- name: Install uv
140134
uses: astral-sh/setup-uv@v5
@@ -143,8 +137,18 @@ jobs:
143137
run: |
144138
uv venv
145139
source .venv/bin/activate
146-
140+
141+
- name: Set up environment
142+
run: |
143+
# Safely write prompt to file
144+
mkdir -p /tmp/claude-input
145+
echo "${{ fromJSON(needs.check-mention.outputs.result).prompt }}" > /tmp/claude-input/prompt.txt
146+
147147
- name: Create structured Claude prompt
148+
env:
149+
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
150+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
151+
GH_TOKEN: ${{ secrets.PAT_FOR_PR }}
148152
run: |
149153
cat > /tmp/claude-input/claude_prompt.txt << EOL
150154
You are @dragon-ai-agent.
@@ -171,13 +175,16 @@ jobs:
171175

172176
- name: Run Claude Code in headless mode
173177
id: claude-response
178+
env:
179+
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
180+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
174181
run: |
175-
# Python env
176-
source .venv/bin/activate
182+
183+
export PATH="${{ env.TOOLS_DIR }}:$PATH"
177184
178185
# Run Claude with proper permissions
179186
claude -p "$(cat /tmp/claude-input/claude_prompt.txt)" \
187+
--permission-mode bypassPermissions \
180188
--output-format stream-json \
181-
--allowedTools "Bash(git:*)" "Bash(gh:*)" "FileSystem(*)" \
182189
--verbose
183190

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,16 @@ CBORG_API_KEY
9797
After setting up env vars:
9898

9999
`just -f ai.just setup-ai`
100+
101+
# FAQ
102+
103+
## `claude-review.yml` fails PR check on first run
104+
105+
This is normal: see this comment in the action logs:
106+
107+
```
108+
Error: Failed to setup GitHub token: Error: Workflow validation failed. The workflow file must exist and have identical content to the version on the repository's default branch. If you're seeing this on a PR when you first add a code review workflow file to your repository, this is normal and you should ignore this error.
109+
110+
If you instead wish to use this action with a custom GitHub token or custom GitHub app, provide a `github_token` in the `uses` section of the app in your workflow yml file.
111+
Error: Process completed with exit code 1.
112+
```

copier.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ project_slug:
3131
{% endif %}
3232
3333
github_handle:
34-
help: github username of the author. Will be assigned as a-controller
34+
help: github username of the author. Will be assigned as ai-controller
3535
type: str
3636
default: "cmungall"
3737

@@ -86,7 +86,7 @@ _message_after_copy: |
8686
8787
3. if your project is already on GitHub, and your keys are set as env vars, then run:
8888
89-
`just setup-ai`
89+
`just -f ai.just setup-ai`
9090
9191
9292

0 commit comments

Comments
 (0)