Skip to content

Commit 926349f

Browse files
bdougieContinue
andcommitted
fix: make github-token optional for backward compatibility
- Changed github-token input from required to optional with default fallback - Made GitHub App token generation conditional on secrets availability - Updated all token references to fallback to github.token when not provided - Ensures existing workflows without App credentials continue to work This maintains compatibility with current users who don't pass github-token explicitly or don't have GitHub App credentials configured. Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
1 parent 7000ec5 commit 926349f

4 files changed

Lines changed: 429 additions & 7 deletions

File tree

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
name: Continue Code Review (Debug)
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, ready_for_review]
5+
issue_comment:
6+
types: [created]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
issues: write
12+
13+
jobs:
14+
review:
15+
if: |
16+
github.event_name == 'pull_request' ||
17+
(github.event_name == 'issue_comment' &&
18+
github.event.issue.pull_request &&
19+
contains(github.event.comment.body, '@review-bot'))
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Generate App Token (Optional)
28+
id: generate_token
29+
uses: actions/create-github-app-token@v1
30+
if: vars.APP_ID && secrets.APP_PRIVATE_KEY
31+
with:
32+
app-id: ${{ vars.APP_ID }}
33+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
40+
- name: Validate Continue API Key
41+
run: |
42+
echo "🔍 Checking if CONTINUE_API_KEY is set..."
43+
if [ -z "${{ secrets.CONTINUE_API_KEY }}" ]; then
44+
echo "❌ ERROR: CONTINUE_API_KEY secret is not set!"
45+
echo "Please add it in Settings → Secrets and variables → Actions"
46+
echo "Get your key from: https://hub.continue.dev/settings/api-keys"
47+
exit 1
48+
else
49+
echo "✅ CONTINUE_API_KEY is set (length: ${#CONTINUE_API_KEY})"
50+
fi
51+
env:
52+
CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }}
53+
54+
- name: Install Continue CLI
55+
run: |
56+
echo "📦 Installing Continue CLI..."
57+
npm i -g @continuedev/cli
58+
echo "✅ Continue CLI installed"
59+
echo "🔍 Checking Continue CLI version..."
60+
cn --version || echo "⚠️ Warning: Could not get CLI version"
61+
62+
- name: Verify Continue CLI Installation
63+
run: |
64+
echo "🔍 Verifying Continue CLI installation..."
65+
which cn || echo "❌ ERROR: cn command not found in PATH"
66+
cn --help || echo "❌ ERROR: cn --help failed"
67+
68+
- name: Get PR Details
69+
id: pr
70+
env:
71+
GH_TOKEN: ${{ steps.generate_token.outputs.token || github.token }}
72+
run: |
73+
echo "🔍 Getting PR details..."
74+
if [ "${{ github.event_name }}" = "issue_comment" ]; then
75+
PR_NUMBER=$(jq -r .issue.number "$GITHUB_EVENT_PATH")
76+
else
77+
PR_NUMBER=$(jq -r .pull_request.number "$GITHUB_EVENT_PATH")
78+
fi
79+
80+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
81+
echo "✅ PR Number: $PR_NUMBER"
82+
83+
echo "📥 Fetching PR diff..."
84+
gh pr diff $PR_NUMBER > pr.diff || {
85+
echo "❌ ERROR: Failed to fetch PR diff"
86+
exit 1
87+
}
88+
echo "✅ PR diff saved ($(wc -l < pr.diff) lines)"
89+
90+
echo "📁 Fetching changed files..."
91+
gh pr view $PR_NUMBER --json files -q '.files[].path' > changed_files.txt || {
92+
echo "❌ ERROR: Failed to fetch changed files"
93+
exit 1
94+
}
95+
echo "✅ Changed files saved ($(wc -l < changed_files.txt) files)"
96+
97+
echo "📋 Changed files:"
98+
cat changed_files.txt
99+
100+
- name: Check for Custom Rules
101+
run: |
102+
echo "🔍 Checking for custom rules in .continue/rules/..."
103+
if [ -d ".continue/rules" ]; then
104+
echo "✅ Found .continue/rules directory"
105+
echo "📋 Custom rules:"
106+
find .continue/rules -name "*.md" -o -name "*.txt" || echo "No rule files found"
107+
else
108+
echo "ℹ️ No custom rules directory found (this is optional)"
109+
fi
110+
111+
- name: Run Continue Review
112+
env:
113+
CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }}
114+
run: |
115+
echo "🤖 Running Continue code review..."
116+
117+
CHANGED_FILES=$(cat changed_files.txt | tr '\n' ' ')
118+
DIFF=$(cat pr.diff)
119+
120+
# Check if running from issue comment
121+
if [ "${{ github.event_name }}" = "issue_comment" ]; then
122+
COMMENT_BODY="${{ github.event.comment.body }}"
123+
CUSTOM_REQUEST=$(echo "$COMMENT_BODY" | sed -n 's/.*@review-bot check for \(.*\)/\1/p')
124+
if [ -n "$CUSTOM_REQUEST" ]; then
125+
echo "📝 Custom review request: $CUSTOM_REQUEST"
126+
FOCUS="Focus specifically on: $CUSTOM_REQUEST"
127+
fi
128+
fi
129+
130+
PROMPT="You are an expert code reviewer. Review the following pull request changes.
131+
132+
Changed files:
133+
$CHANGED_FILES
134+
135+
Diff:
136+
\`\`\`diff
137+
$DIFF
138+
\`\`\`
139+
140+
${FOCUS:-Review the code for potential issues, bugs, security concerns, and improvements.}
141+
142+
Provide your review in the following markdown format:
143+
144+
## Summary
145+
Brief overview of the changes
146+
147+
## Key Findings
148+
- List any issues, bugs, or security concerns
149+
- Suggest improvements
150+
151+
## Positive Observations
152+
- Note good practices
153+
154+
## Recommendations
155+
- Actionable suggestions"
156+
157+
echo "🔍 Prompt length: ${#PROMPT} characters"
158+
echo "🔍 Running: cn --config continuedev/code-reviewer -p \"...\" --auto"
159+
160+
cn --config continuedev/code-reviewer \
161+
-p "$PROMPT" \
162+
--auto > review_output.md 2>&1 || {
163+
EXIT_CODE=$?
164+
echo "❌ ERROR: Continue review failed with exit code $EXIT_CODE"
165+
echo "📋 Output:"
166+
cat review_output.md
167+
echo ""
168+
echo "🔍 Debugging information:"
169+
echo " - Continue API Key length: ${#CONTINUE_API_KEY}"
170+
echo " - Config: continuedev/code-reviewer"
171+
echo " - Prompt length: ${#PROMPT}"
172+
echo ""
173+
echo "💡 Common issues:"
174+
echo " 1. Invalid or expired CONTINUE_API_KEY"
175+
echo " 2. Assistant 'continuedev/code-reviewer' not found or not accessible"
176+
echo " 3. Continue Hub account issues"
177+
echo ""
178+
echo "🔧 Troubleshooting steps:"
179+
echo " 1. Verify your API key at https://hub.continue.dev/settings/api-keys"
180+
echo " 2. Check that you have access to the code-reviewer assistant"
181+
echo " 3. Try creating a custom assistant for code reviews"
182+
exit $EXIT_CODE
183+
}
184+
185+
echo "✅ Review completed successfully"
186+
echo "📋 Review output:"
187+
cat review_output.md
188+
189+
- name: Post Review Comment
190+
env:
191+
GH_TOKEN: ${{ steps.generate_token.outputs.token || github.token }}
192+
run: |
193+
echo "💬 Posting review comment..."
194+
195+
PR_NUMBER="${{ steps.pr.outputs.PR_NUMBER }}"
196+
REVIEW_BODY=$(cat review_output.md)
197+
198+
COMMENT_BODY="## 🤖 AI Code Review
199+
200+
$REVIEW_BODY
201+
202+
---
203+
*Powered by Continue • Need a focused review? Comment \`@review-bot check for [specific concern]\`*"
204+
205+
# Check for existing review comment
206+
EXISTING_COMMENT=$(gh api \
207+
repos/${{ github.repository }}/issues/$PR_NUMBER/comments \
208+
--jq '.[] | select(.body | contains("🤖 AI Code Review")) | .id' \
209+
| head -n 1)
210+
211+
if [ -n "$EXISTING_COMMENT" ]; then
212+
echo "🔄 Updating existing comment (ID: $EXISTING_COMMENT)..."
213+
gh api \
214+
--method PATCH \
215+
repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT \
216+
-f body="$COMMENT_BODY"
217+
echo "✅ Comment updated"
218+
else
219+
echo "✨ Creating new comment..."
220+
gh pr comment $PR_NUMBER --body "$COMMENT_BODY"
221+
echo "✅ Comment created"
222+
fi
223+
224+
- name: Upload Artifacts (Debug)
225+
if: always()
226+
uses: actions/upload-artifact@v4
227+
with:
228+
name: review-debug-artifacts
229+
path: |
230+
pr.diff
231+
changed_files.txt
232+
review_output.md
233+
retention-days: 7

.github/workflows/continue-general-review.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- name: Generate GitHub App Token
2424
id: generate-token
2525
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v2.0.0
26+
if: secrets.CONTINUE_APP_ID != '' && secrets.CONTINUE_APP_PRIVATE_KEY != ''
2627
with:
2728
app-id: ${{ secrets.CONTINUE_APP_ID }}
2829
private-key: ${{ secrets.CONTINUE_APP_PRIVATE_KEY }}
@@ -33,4 +34,4 @@ jobs:
3334
continue-api-key: ${{ secrets.CONTINUE_API_KEY }}
3435
continue-org: "continuedev"
3536
continue-agent: "empty-agent"
36-
github-token: ${{ steps.generate-token.outputs.token }}
37+
github-token: ${{ steps.generate-token.outputs.token || github.token }}

0 commit comments

Comments
 (0)