Skip to content

Commit a884852

Browse files
committed
Support OAuth authentication for self-hosted runners
1 parent 6eec126 commit a884852

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

.github/workflows/pr-automation.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,13 @@ jobs:
170170
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171171
run: |
172172
set -eo pipefail
173-
# Use secret if set, otherwise use runner's env
173+
# Use secret if set, otherwise use runner's env (or OAuth from keychain)
174174
[ -n "$ANTHROPIC_API_KEY_SECRET" ] && export ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY_SECRET"
175175
176-
# Check API key is available
177-
if [ -z "$ANTHROPIC_API_KEY" ]; then
178-
echo "Error: ANTHROPIC_API_KEY not set" | tee claude-output.txt
176+
# For GitHub-hosted runners, API key is required
177+
# For self-hosted runners, OAuth from keychain is also supported
178+
if [ -z "$ANTHROPIC_API_KEY" ] && [ "${{ vars.RUNNER_TYPE }}" != "self-hosted" ]; then
179+
echo "Error: ANTHROPIC_API_KEY not set (required for GitHub-hosted runners)" | tee claude-output.txt
179180
exit 1
180181
fi
181182
@@ -204,19 +205,26 @@ jobs:
204205
exit 1
205206
fi
206207
208+
# Check for max turns exhaustion
209+
if grep -q "Reached max turns" claude-output.txt; then
210+
echo "Error: Claude exhausted max turns without completing"
211+
exit 1
212+
fi
213+
207214
- name: Fix issues
208215
if: needs.setup.outputs.command == 'fix'
209216
env:
210217
ANTHROPIC_API_KEY_SECRET: ${{ secrets.ANTHROPIC_API_KEY }}
211218
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
212219
run: |
213220
set -eo pipefail
214-
# Use secret if set, otherwise use runner's env
221+
# Use secret if set, otherwise use runner's env (or OAuth from keychain)
215222
[ -n "$ANTHROPIC_API_KEY_SECRET" ] && export ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY_SECRET"
216223
217-
# Check API key is available
218-
if [ -z "$ANTHROPIC_API_KEY" ]; then
219-
echo "Error: ANTHROPIC_API_KEY not set" | tee claude-output.txt
224+
# For GitHub-hosted runners, API key is required
225+
# For self-hosted runners, OAuth from keychain is also supported
226+
if [ -z "$ANTHROPIC_API_KEY" ] && [ "${{ vars.RUNNER_TYPE }}" != "self-hosted" ]; then
227+
echo "Error: ANTHROPIC_API_KEY not set (required for GitHub-hosted runners)" | tee claude-output.txt
220228
exit 1
221229
fi
222230
@@ -278,6 +286,12 @@ jobs:
278286
exit 1
279287
fi
280288
289+
# Check for max turns exhaustion
290+
if grep -q "Reached max turns" claude-output.txt; then
291+
echo "Error: Claude exhausted max turns without completing"
292+
exit 1
293+
fi
294+
281295
- name: Debug test
282296
if: needs.setup.outputs.command == 'debug'
283297
run: |

0 commit comments

Comments
 (0)