From 63f1d1767dddf4b7496381b484694e586c824564 Mon Sep 17 00:00:00 2001 From: Chris Carini <6374067+ChrisCarini@users.noreply.github.com> Date: Mon, 8 Sep 2025 08:45:37 -0700 Subject: [PATCH 1/5] Add `automatically-request-copilot-review.yaml` workflow (#1) --- .../automatically-request-copilot-review.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/automatically-request-copilot-review.yaml diff --git a/.github/workflows/automatically-request-copilot-review.yaml b/.github/workflows/automatically-request-copilot-review.yaml new file mode 100644 index 000000000..23e56172c --- /dev/null +++ b/.github/workflows/automatically-request-copilot-review.yaml @@ -0,0 +1,24 @@ +name: Automatic Copilot Code Review + +on: + pull_request: + types: + - opened # brand-new PRs + - ready_for_review # PR drafts marked "Ready for review" + - reopened # PRs that were closed then reopened + - synchronize # PRs updated with new commits + +jobs: + add-copilot-to-pr-reviews: + name: "Add Copilot to PR reviews" + if: ${{ github.event.pull_request.draft == false }} # skip still-draft PRs + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.GH_TOKEN_COPILOT_REVIEW }} # gh CLI picks this up automatically + + steps: + - name: Install gh-copilot-review extension + run: gh extension install ChrisCarini/gh-copilot-review + + - name: Ask Copilot to review this PR + run: gh copilot-review "${{ github.event.pull_request.html_url }}" From 36a1dfd9fabcf0602de17c5747bdf4294edcedb6 Mon Sep 17 00:00:00 2001 From: Steven Shimizu Date: Sun, 21 Sep 2025 13:26:13 -0700 Subject: [PATCH 2/5] Trying to fix the install --- .github/workflows/automatically-request-copilot-review.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automatically-request-copilot-review.yaml b/.github/workflows/automatically-request-copilot-review.yaml index 23e56172c..bc1096c4e 100644 --- a/.github/workflows/automatically-request-copilot-review.yaml +++ b/.github/workflows/automatically-request-copilot-review.yaml @@ -13,12 +13,14 @@ jobs: name: "Add Copilot to PR reviews" if: ${{ github.event.pull_request.draft == false }} # skip still-draft PRs runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ secrets.GH_TOKEN_COPILOT_REVIEW }} # gh CLI picks this up automatically steps: - name: Install gh-copilot-review extension + env: + GH_TOKEN: ${{ github.token }} run: gh extension install ChrisCarini/gh-copilot-review - name: Ask Copilot to review this PR + env: + GH_TOKEN: ${{ secrets.GH_TOKEN_COPILOT_REVIEW }} # gh CLI picks this up automatically run: gh copilot-review "${{ github.event.pull_request.html_url }}" From 77c304d6e36480f1c7c8da594909fcab67314b8b Mon Sep 17 00:00:00 2001 From: Steven Shimizu Date: Sun, 21 Sep 2025 13:52:25 -0700 Subject: [PATCH 3/5] Run in separate environment to access secret --- .github/workflows/automatically-request-copilot-review.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/automatically-request-copilot-review.yaml b/.github/workflows/automatically-request-copilot-review.yaml index bc1096c4e..171690787 100644 --- a/.github/workflows/automatically-request-copilot-review.yaml +++ b/.github/workflows/automatically-request-copilot-review.yaml @@ -13,6 +13,7 @@ jobs: name: "Add Copilot to PR reviews" if: ${{ github.event.pull_request.draft == false }} # skip still-draft PRs runs-on: ubuntu-latest + environment: copilot-review steps: - name: Install gh-copilot-review extension From e6a293ce63f885a9b791629e1f6b28f1986ef84e Mon Sep 17 00:00:00 2001 From: Steven Shimizu Date: Sun, 21 Sep 2025 14:02:28 -0700 Subject: [PATCH 4/5] Debugging environment --- .../automatically-request-copilot-review.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/automatically-request-copilot-review.yaml b/.github/workflows/automatically-request-copilot-review.yaml index 171690787..029fbc965 100644 --- a/.github/workflows/automatically-request-copilot-review.yaml +++ b/.github/workflows/automatically-request-copilot-review.yaml @@ -16,6 +16,24 @@ jobs: environment: copilot-review steps: + - name: Debug environment and secrets + run: | + echo "Environment: copilot-review" + echo "Repository: ${{ github.repository }}" + echo "PR from repo: ${{ github.event.pull_request.head.repo.full_name }}" + echo "Is fork: ${{ github.event.pull_request.head.repo.full_name != github.repository }}" + echo "Secret exists: ${{ secrets.GH_TOKEN_COPILOT_REVIEW != '' }}" + echo "Secret length: ${#GH_TOKEN_COPILOT_REVIEW}" + env: + GH_TOKEN_COPILOT_REVIEW: ${{ secrets.GH_TOKEN_COPILOT_REVIEW }} + + - name: Test GitHub token + env: + GH_TOKEN: ${{ github.token }} + run: | + echo "Testing default GitHub token..." + gh auth status + - name: Install gh-copilot-review extension env: GH_TOKEN: ${{ github.token }} From 27e3cbddcf9992897dbc307244ec6845a855d238 Mon Sep 17 00:00:00 2001 From: Steven Shimizu Date: Sun, 21 Sep 2025 14:06:36 -0700 Subject: [PATCH 5/5] Change to pull_request_target --- .github/workflows/automatically-request-copilot-review.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatically-request-copilot-review.yaml b/.github/workflows/automatically-request-copilot-review.yaml index 029fbc965..a7971d9e9 100644 --- a/.github/workflows/automatically-request-copilot-review.yaml +++ b/.github/workflows/automatically-request-copilot-review.yaml @@ -1,7 +1,7 @@ name: Automatic Copilot Code Review on: - pull_request: + pull_request_target: types: - opened # brand-new PRs - ready_for_review # PR drafts marked "Ready for review"