99 continue-org :
1010 description : " Organization for Continue config"
1111 required : true
12- continue-config :
13- description : ' Config path to use (e.g., "myorg/review-bot")'
12+ continue-agent :
13+ description : ' Agent path to use (e.g., "myorg/review-bot")'
1414 required : true
1515
1616runs :
@@ -20,44 +20,89 @@ runs:
2020 uses : actions/checkout@v4
2121
2222 - name : Check Authorization
23- shell : bash
24- env :
25- # Only move the dangerous check to env to prevent shell injection
26- HAS_TRIGGER_PHRASE : ${{ contains(github.event.comment.body, '@continue-review') }}
27- run : |
28- # Check if this action should run based on event type and user permissions
29- SHOULD_RUN="false"
23+ id : auth-check
24+ uses : actions/github-script@v7
25+ with :
26+ script : |
27+ let shouldRun = false;
28+ let skipReason = '';
3029
31- if [ "${{ github.event_name }}" = "pull_request" ]; then
32- # Check if PR is a draft
33- if [ "${{ github.event.pull_request.draft }}" = "true" ]; then
34- echo "::notice::Skipping review - PR is a draft"
35- else
36- # Check PR author association
37- AUTHOR_ASSOC="${{ github.event.pull_request.author_association }}"
38- if [ "$AUTHOR_ASSOC" = "OWNER" ] || [ "$AUTHOR_ASSOC" = "MEMBER" ] || [ "$AUTHOR_ASSOC" = "COLLABORATOR" ]; then
39- SHOULD_RUN="true"
40- else
41- echo "::notice::Skipping review - PR author is not a team member (association: $AUTHOR_ASSOC)"
42- fi
43- fi
44- elif [ "${{ github.event_name }}" = "issue_comment" ]; then
45- # Check if it's a PR comment with the trigger phrase
46- if [ "${{ github.event.issue.pull_request }}" != "" ] && [ "$HAS_TRIGGER_PHRASE" = "true" ]; then
47- COMMENTER_ASSOC="${{ github.event.comment.author_association }}"
48- if [ "$COMMENTER_ASSOC" = "OWNER" ] || [ "$COMMENTER_ASSOC" = "MEMBER" ] || [ "$COMMENTER_ASSOC" = "COLLABORATOR" ]; then
49- SHOULD_RUN="true"
50- else
51- echo "::notice::Skipping review - Commenter is not a team member (association: $COMMENTER_ASSOC)"
52- fi
53- else
54- echo "::notice::Skipping review - Comment does not contain @continue-review trigger, or is not on a PR"
55- fi
56- else
57- echo "::notice::Skipping review - Unsupported event type: ${{ github.event_name }}"
58- fi
30+ if (context.eventName === 'pull_request') {
31+ // Check if PR is a draft
32+ if (context.payload.pull_request.draft) {
33+ skipReason = 'PR is a draft';
34+ } else {
35+ // Check if user has write permission (includes admin, maintain, write)
36+ const prAuthor = context.payload.pull_request.user.login;
37+ try {
38+ const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
39+ owner: context.repo.owner,
40+ repo: context.repo.repo,
41+ username: prAuthor
42+ });
43+
44+ const allowedPermissions = ['admin', 'maintain', 'write'];
45+ if (allowedPermissions.includes(permission.permission)) {
46+ shouldRun = true;
47+ console.log(`PR author @${prAuthor} has ${permission.permission} permission`);
48+ } else {
49+ skipReason = `PR author @${prAuthor} does not have write permission (has: ${permission.permission})`;
50+ }
51+ } catch (error) {
52+ // If API call fails, fall back to checking author_association
53+ const association = context.payload.pull_request.author_association;
54+ const allowedAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR'];
55+ if (allowedAssociations.includes(association)) {
56+ shouldRun = true;
57+ console.log(`PR author @${prAuthor} association: ${association}`);
58+ } else {
59+ skipReason = `PR author @${prAuthor} is not a team member (association: ${association})`;
60+ }
61+ }
62+ }
63+ } else if (context.eventName === 'issue_comment') {
64+ // Check if it's a PR comment with the trigger phrase
65+ const hasTrigger = context.payload.comment.body.includes('@continue-review');
66+ if (context.payload.issue.pull_request && hasTrigger) {
67+ const commenter = context.payload.comment.user.login;
68+ try {
69+ const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
70+ owner: context.repo.owner,
71+ repo: context.repo.repo,
72+ username: commenter
73+ });
74+
75+ const allowedPermissions = ['admin', 'maintain', 'write'];
76+ if (allowedPermissions.includes(permission.permission)) {
77+ shouldRun = true;
78+ console.log(`Commenter @${commenter} has ${permission.permission} permission`);
79+ } else {
80+ skipReason = `Commenter @${commenter} does not have write permission (has: ${permission.permission})`;
81+ }
82+ } catch (error) {
83+ // If API call fails, fall back to checking author_association
84+ const association = context.payload.comment.author_association;
85+ const allowedAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR'];
86+ if (allowedAssociations.includes(association)) {
87+ shouldRun = true;
88+ console.log(`Commenter @${commenter} association: ${association}`);
89+ } else {
90+ skipReason = `Commenter @${commenter} is not a team member (association: ${association})`;
91+ }
92+ }
93+ } else {
94+ skipReason = 'Comment does not contain @continue-review trigger, or is not on a PR';
95+ }
96+ } else {
97+ skipReason = `Unsupported event type: ${context.eventName}`;
98+ }
99+
100+ if (skipReason) {
101+ core.notice(`Skipping review - ${skipReason}`);
102+ }
59103
60- echo "SHOULD_RUN=$SHOULD_RUN" >> $GITHUB_ENV
104+ core.exportVariable('SHOULD_RUN', shouldRun.toString());
105+ return shouldRun;
61106
62107 - name : Setup Node.js
63108 if : env.SHOULD_RUN == 'true'
68113 - name : Install Continue CLI
69114 if : env.SHOULD_RUN == 'true'
70115 shell : bash
71- run : npm install -g @continuedev/cli@1.4.30
116+ run : npm install -g @continuedev/cli@latest
72117
73118 - name : Post Initial Comment
74119 if : env.SHOULD_RUN == 'true'
@@ -182,7 +227,7 @@ runs:
182227 env :
183228 CONTINUE_API_KEY : ${{ inputs.continue-api-key }}
184229 CONTINUE_ORG : ${{ inputs.continue-org }}
185- CONTINUE_CONFIG : ${{ inputs.continue-config }}
230+ CONTINUE_AGENT : ${{ inputs.continue-agent }}
186231 GITHUB_TOKEN : ${{ github.token }}
187232 run : |
188233 echo "Running Continue CLI with prompt:"
@@ -208,7 +253,7 @@ runs:
208253 exit 1
209254 fi
210255
211- if [[ ! "$CONTINUE_CONFIG " =~ ^[a-zA-Z0-9_/-]+$ ]]; then
256+ if [[ ! "$CONTINUE_AGENT " =~ ^[a-zA-Z0-9_/-]+$ ]]; then
212257 echo "Error: Invalid config path. Must contain only alphanumeric characters, hyphens, underscores, and forward slashes."
213258 exit 1
214259 fi
@@ -228,7 +273,7 @@ runs:
228273
229274 # Run the CLI with validated config and error handling
230275 if [ "$SKIP_CLI" != "true" ]; then
231- echo "Executing Continue CLI with config: $CONTINUE_ORG/$CONTINUE_CONFIG "
276+ echo "Executing Continue CLI with config: $CONTINUE_ORG/$CONTINUE_AGENT "
232277
233278 # Write prompt to temp file for headless mode
234279 PROMPT_FILE="/tmp/continue-review-$RANDOM.txt"
@@ -237,9 +282,9 @@ runs:
237282 echo "Prompt length: $(wc -c < "$PROMPT_FILE") characters"
238283
239284 # Use timeout to prevent hanging (360 seconds = 6 minutes)
240- echo "Executing command: cn --config $CONTINUE_ORG/$CONTINUE_CONFIG -p @$PROMPT_FILE --allow Bash"
285+ echo "Executing command: cn --agent $CONTINUE_ORG/$CONTINUE_AGENT -p @$PROMPT_FILE --allow Bash"
241286
242- if timeout 360 cn --config "$CONTINUE_ORG/$CONTINUE_CONFIG " -p "@$PROMPT_FILE" --allow Bash > code_review_raw.md 2>cli_error.log; then
287+ if timeout 360 cn --agent "$CONTINUE_ORG/$CONTINUE_AGENT " -p "@$PROMPT_FILE" --allow Bash > code_review_raw.md 2>cli_error.log; then
243288 echo "Continue CLI completed successfully"
244289 echo "Raw output length: $(wc -c < code_review_raw.md) characters"
245290
0 commit comments