Skip to content

Commit 11e449b

Browse files
committed
fix: use PAT_TOKEN for @copilot mentions so they post as MervinPraison
Copilot ignores @copilot mentions from github-actions[bot]. Switching to PAT_TOKEN makes comments appear from a real user.
1 parent d9581f3 commit 11e449b

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

.github/workflows/auto-pr-comment.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Auto PR Comment
33
# Review chain: CodeRabbit/Qodo/Gemini review first → THEN trigger Copilot
44
# For human PRs: CodeRabbit/Qodo auto-review → this workflow triggers Copilot
55
# For bot PRs: CodeRabbit/Qodo skip bots, so we trigger them explicitly first
6+
#
7+
# IMPORTANT: @copilot ignores bot comments. All @copilot mentions must use
8+
# PAT_TOKEN so the comment posts as MervinPraison (a real user).
69
on:
710
issue_comment:
811
types: [created]
@@ -25,18 +28,20 @@ jobs:
2528
permissions:
2629
pull-requests: write
2730
steps:
28-
- name: Post Copilot review request
31+
- name: Post Copilot review request (as user via PAT)
2932
uses: actions/github-script@v7
3033
with:
31-
github-token: ${{ secrets.GITHUB_TOKEN }}
34+
github-token: ${{ secrets.PAT_TOKEN }}
3235
script: |
3336
const comments = await github.rest.issues.listComments({
3437
issue_number: context.issue.number,
3538
owner: context.repo.owner,
3639
repo: context.repo.repo
3740
});
38-
const alreadyPosted = comments.data.some(c =>
39-
c.user.login === 'github-actions[bot]' && c.body.includes('@copilot')
41+
// Check for duplicates — posted by MervinPraison (PAT) or github-actions[bot] (legacy)
42+
const alreadyPosted = comments.data.some(c =>
43+
c.body.includes('@copilot') &&
44+
(c.user.login === 'MervinPraison' || c.user.login === 'github-actions[bot]')
4045
);
4146
if (alreadyPosted) {
4247
console.log('Copilot already triggered, skipping');
@@ -58,18 +63,19 @@ jobs:
5863
permissions:
5964
pull-requests: write
6065
steps:
61-
- name: Post Copilot review request (fallback via Qodo)
66+
- name: Post Copilot review request (as user via PAT)
6267
uses: actions/github-script@v7
6368
with:
64-
github-token: ${{ secrets.GITHUB_TOKEN }}
69+
github-token: ${{ secrets.PAT_TOKEN }}
6570
script: |
6671
const comments = await github.rest.issues.listComments({
6772
issue_number: context.issue.number,
6873
owner: context.repo.owner,
6974
repo: context.repo.repo
7075
});
71-
const alreadyPosted = comments.data.some(c =>
72-
c.user.login === 'github-actions[bot]' && c.body.includes('@copilot')
76+
const alreadyPosted = comments.data.some(c =>
77+
c.body.includes('@copilot') &&
78+
(c.user.login === 'MervinPraison' || c.user.login === 'github-actions[bot]')
7379
);
7480
if (alreadyPosted) {
7581
console.log('Copilot already triggered, skipping');
@@ -86,7 +92,6 @@ jobs:
8692
# BOT PRs: CodeRabbit/Qodo skip bot-authored PRs by default.
8793
# Trigger them explicitly. Do NOT trigger Copilot here — it will
8894
# be triggered by copilot-after-coderabbit/qodo when they finish.
89-
# Chain: trigger reviews → CodeRabbit/Qodo post → Copilot triggered → Claude chains
9095
# ================================================================
9196
bot-pr-trigger-reviews:
9297
if: |
@@ -100,7 +105,7 @@ jobs:
100105
- name: Trigger CodeRabbit, Qodo, and Gemini reviews
101106
uses: actions/github-script@v7
102107
with:
103-
github-token: ${{ secrets.GITHUB_TOKEN }}
108+
github-token: ${{ secrets.PAT_TOKEN }}
104109
script: |
105110
const pr = context.payload.pull_request.number;
106111
const owner = context.repo.owner;
@@ -128,7 +133,6 @@ jobs:
128133
console.log(`Triggered Gemini for bot PR #${pr}`);
129134
130135
// NOTE: @copilot is NOT triggered here.
131-
// It will be triggered automatically by copilot-after-coderabbit
132-
// or copilot-after-qodo when those bots finish their reviews.
133-
// This ensures Copilot always reviews AFTER all other reviewers.
136+
// It will be triggered by copilot-after-coderabbit or copilot-after-qodo
137+
// once those bots finish, ensuring Copilot always reviews LAST.
134138
console.log('Copilot will be triggered after CodeRabbit/Qodo complete.');

0 commit comments

Comments
 (0)