Add automation for Copilot reviews and auto-merge#932
Conversation
| assignees, | ||
| }); | ||
| } catch (error) { | ||
| core.warning(`Unable to assign copilot: ${error.message}`); |
There was a problem hiding this comment.
I think the workflow will always succeed. How do we identify runs where an error actually occurred?
There was a problem hiding this comment.
I don't understand if it fails, we should get a warning I suppose?
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR introduces GitHub Actions automation around issue assignment, PR review requests, and automatic merging after review approval, to streamline Copilot-related workflows in this repo.
Changes:
- Add a workflow to automatically request PR reviewers when a PR is opened, reopened, or marked ready for review.
- Add a workflow that, on review approval, attempts to auto-approve pending workflow runs and then merge the PR.
- Add a workflow that auto-assigns Copilot to new issues.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.github/workflows/request-pr-reviews.yml |
New workflow that triggers on PR events and uses actions/github-script to request a fixed set of reviewers, skipping the PR author. |
.github/workflows/auto-merge-on-approval.yml |
New workflow that reacts to pull_request_review approvals, auto-approves pending workflow runs for maintainers, and then merges eligible PRs via the REST API. |
.github/workflows/assign-copilot-issues.yml |
New workflow that assigns a copilot account to newly opened issues using actions/github-script. |
| const requested = ["hzxa21", "tabVersion", "kwannoel"]; | ||
| const author = context.payload.pull_request.user?.login; | ||
| const reviewers = requested.filter((login) => login && login !== author); |
There was a problem hiding this comment.
The PR description mentions that this workflow should request PR reviews "including Copilot", but the requested array here only contains these three user logins and does not include a Copilot account. Either add the Copilot reviewer here (if it has a GitHub login such as a bot/user account) or update the PR description to match the actual behavior.
| - name: Merge pull request | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const pr = context.payload.pull_request; | ||
|
|
||
| if (!pr || pr.state !== "open") { | ||
| core.info("Pull request is not open."); | ||
| return; | ||
| } | ||
|
|
||
| if (pr.draft) { | ||
| core.info("Pull request is draft."); | ||
| return; | ||
| } | ||
|
|
||
| if (pr.merged) { | ||
| core.info("Pull request already merged."); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| await github.rest.pulls.merge({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: pr.number, | ||
| merge_method: "merge", | ||
| }); |
There was a problem hiding this comment.
This merge step runs for any approved review without checking the reviewer’s repository permission level, so even a reviewer without admin/maintain/write access can cause the workflow (via GITHUB_TOKEN) to merge the PR. In addition, the merge happens immediately on approval without verifying that all required CI workflows have completed successfully, which can merge untested or failing code. Consider reusing the permission check from the previous step (or gating the job itself) and adding an explicit check that all required status checks have passed before calling github.rest.pulls.merge.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
kwannoel
left a comment
There was a problem hiding this comment.
Simplified it a lot.
177c7e4 to
e170b3e
Compare
Description
Add a workflow that assigns Copilot to newly opened issues.
Related code PR
N/A
Related doc issue
N/A
Fix N/A
Checklist
mint.jsonto include the page in the table of contents.