Request Copilot review workflow (xarray-contrib/xarray-spatial)
The Request Copilot review workflow from xarray-contrib/xarray-spatial, explained and optimized by Latchkey.
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Request Copilot review workflow from the xarray-contrib/xarray-spatial repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Request Copilot review
on:
pull_request_target:
types: [opened, reopened, ready_for_review]
permissions:
pull-requests: write
jobs:
request-copilot-review:
# Same-repo PRs only. author_association in the pull_request_target payload
# reports CONTRIBUTOR for org members on same-repo branches, so head==base
# is the reliable maintainer signal (it requires push access to the base repo).
if: >-
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Request Copilot review
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"/repos/${REPO}/pulls/${PR_NUMBER}/requested_reviewers" \
-f "reviewers[]=Copilot"
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Request Copilot review on: pull_request_target: types: [opened, reopened, ready_for_review] permissions: pull-requests: write jobs: request-copilot-review: timeout-minutes: 30 # Same-repo PRs only. author_association in the pull_request_target payload # reports CONTRIBUTOR for org members on same-repo branches, so head==base # is the reliable maintainer signal (it requires push access to the base repo). if: >- github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name runs-on: latchkey-small steps: - name: Request Copilot review env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} REPO: ${{ github.repository }} run: | gh api \ --method POST \ -H "Accept: application/vnd.github+json" \ "/repos/${REPO}/pulls/${PR_NUMBER}/requested_reviewers" \ -f "reviewers[]=Copilot"
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.