Skip to content

Commit b8f3873

Browse files
committed
Fix GitHub workflow to handle missing LLM_API_KEY gracefully
- Make AI review optional when LLM_API_KEY secret is not configured - Add proper error handling and fallback behavior - Update checkout action to v4 - Add informative notices when AI review is skipped - Prevent workflow failure due to missing API key This allows the CI/CD pipeline to continue running even without the LLM API key configured, making it more robust for contributors.
1 parent 9f2129f commit b8f3873

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

.github/workflows/presubmit.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,33 @@ jobs:
1515
review:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- name: Check required secrets
19-
run: |
20-
if [ -z "${{ secrets.LLM_API_KEY }}" ]; then
21-
echo "Error: LLM_API_KEY secret is not configured"
22-
exit 1
23-
fi
24-
2518
- name: Check out PR code
26-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2720
with:
2821
ref: ${{ github.event.pull_request.head.sha }}
2922

23+
- name: Check API key availability
24+
id: check_api_key
25+
run: |
26+
if [ -z "${{ secrets.LLM_API_KEY }}" ]; then
27+
echo "api_key_available=false" >> $GITHUB_OUTPUT
28+
echo "Warning: LLM_API_KEY secret is not configured. AI review will be skipped."
29+
else
30+
echo "api_key_available=true" >> $GITHUB_OUTPUT
31+
echo "LLM_API_KEY is configured. AI review will run."
32+
fi
33+
3034
- name: Run AI Reviewer
35+
if: steps.check_api_key.outputs.api_key_available == 'true'
3136
uses: presubmit/ai-reviewer@latest
3237
env:
3338
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3439
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
3540
LLM_MODEL: "gemini-1.5-flash"
41+
continue-on-error: true
42+
43+
- name: AI Review Skipped Notice
44+
if: steps.check_api_key.outputs.api_key_available == 'false'
45+
run: |
46+
echo "::notice::AI review was skipped because LLM_API_KEY secret is not configured."
47+
echo "To enable AI review, please configure the LLM_API_KEY secret in repository settings."

0 commit comments

Comments
 (0)