@@ -206,15 +206,37 @@ runs:
206206 shell : bash
207207 env :
208208 GH_TOKEN : ${{ env.GITHUB_TOKEN || github.token }}
209+ GITHUB_REPOSITORY : ${{ github.repository }}
209210 run : |
210211 # Get authenticated user (the bot making API calls)
211- echo "Debug: GH_TOKEN is set: $([ -n "$GH_TOKEN" ] && echo 'yes' || echo 'no')"
212- echo "Debug: Attempting to detect bot identity..."
212+ # Note: /user endpoint doesn't work with GitHub App tokens, so we try multiple methods
213+ BOT_LOGIN=""
214+
215+ # Method 1: Try /user endpoint (works for PATs, not GitHub App tokens)
216+ if [ -z "$BOT_LOGIN" ]; then
217+ if BOT_LOGIN_TMP=$(gh api user --jq '.login' 2>/dev/null); then
218+ BOT_LOGIN="$BOT_LOGIN_TMP"
219+ echo "Detected bot via /user endpoint: $BOT_LOGIN"
220+ fi
221+ fi
222+
223+ # Method 2: Try installation endpoint (works for GitHub App tokens)
224+ if [ -z "$BOT_LOGIN" ]; then
225+ if INSTALLATION_DATA=$(gh api "repos/$GITHUB_REPOSITORY/installation" 2>/dev/null); then
226+ APP_SLUG=$(echo "$INSTALLATION_DATA" | jq -r '.app_slug // empty' 2>/dev/null)
227+ if [ -n "$APP_SLUG" ] && [ "$APP_SLUG" != "null" ]; then
228+ BOT_LOGIN="${APP_SLUG}[bot]"
229+ echo "Detected bot via installation endpoint: $BOT_LOGIN"
230+ fi
231+ fi
232+ fi
213233
214- if ! BOT_LOGIN=$(gh api user --jq '.login' 2>&1); then
215- echo "Warning: Failed to detect bot identity (error: $BOT_LOGIN), using default"
234+ # Method 3: Fallback to default
235+ if [ -z " $BOT_LOGIN" ]; then
216236 BOT_LOGIN="github-actions"
237+ echo "Using default bot identity: $BOT_LOGIN"
217238 fi
239+
218240 echo "bot_login=$BOT_LOGIN" >> $GITHUB_OUTPUT
219241 echo "Detected bot identity: $BOT_LOGIN"
220242
@@ -510,9 +532,31 @@ runs:
510532 CLAUDECODE_FINDINGS : ${{ steps.claudecode-scan.outputs.findings_count }}
511533 SILENCE_CLAUDECODE_COMMENTS : ${{ steps.claudecode-check.outputs.silence_claudecode_comments }}
512534 ACTION_PATH : ${{ github.action_path }}
535+ PR_HEAD_SHA : ${{ github.event.pull_request.head.sha || steps.pr-info.outputs.pr_sha }}
513536 run : |
514537 node "$ACTION_PATH/scripts/comment-pr-findings.js"
515538
539+ - name : Request bot as reviewer
540+ if : steps.claudecode-check.outputs.enable_claudecode == 'true'
541+ shell : bash
542+ env :
543+ GH_TOKEN : ${{ env.GITHUB_TOKEN || github.token }}
544+ GITHUB_REPOSITORY : ${{ github.repository }}
545+ PR_NUMBER : ${{ github.event.pull_request.number || steps.pr-info.outputs.pr_number }}
546+ BOT_LOGIN : ${{ steps.bot-identity.outputs.bot_login }}
547+ run : |
548+ # Request the bot as a reviewer to make it appear in the PR's reviewer list
549+ # This is optional and will fail silently if the bot is already a reviewer or doesn't have permissions
550+ echo "Requesting $BOT_LOGIN as reviewer for PR #$PR_NUMBER..."
551+
552+ if gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/requested_reviewers" \
553+ -X POST \
554+ -f "reviewers[]=$BOT_LOGIN" 2>/dev/null; then
555+ echo "Successfully requested $BOT_LOGIN as reviewer"
556+ else
557+ echo "Note: Could not request bot as reviewer (this is normal if bot is already a reviewer or is the PR author)"
558+ fi
559+
516560branding :
517561 icon : ' shield'
518562 color : ' red'
0 commit comments