Repository navigation
87 lines (83 loc) · 3.95 KB
/
Copy pathauto-queue.yml
File metadata and controls
87 lines (83 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Auto queue
# Queue the reviewed head of a maintainer PR after its required checks pass.
# CI completion, reviewer comments and PR changes all re-evaluate the same decision.
# The environment's token must be restricted to main. Never run PR code in this job.
on:
pull_request_target:
types: [ready_for_review, converted_to_draft, synchronize, dequeued]
workflow_run:
workflows: [CI]
types: [completed]
issue_comment:
types: [created, edited, deleted]
permissions:
contents: read
pull-requests: read
concurrency:
group: auto-queue-${{ github.event.pull_request.number || github.event.issue.number || github.event.workflow_run.pull_requests[0].number }}
cancel-in-progress: false
jobs:
queue:
name: Queue when green and reviewed
# Only the maintainer's own pull requests from this repository get past
# this line, so a pull request from a fork never starts a job that names
# the token. Re-evaluate reviewer summaries and the maintainer's queue
# command when those PR comments change.
if: >-
(github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.pull_requests[0].number &&
github.event.workflow_run.head_repository.full_name == github.repository) ||
(github.event_name == 'pull_request_target' &&
github.event.pull_request.user.login == 'n0rpan' &&
github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request &&
github.event.issue.user.login == 'n0rpan' &&
((github.event.comment.user.login == 'chatgpt-codex-connector[bot]' && github.event.comment.user.type == 'Bot') ||
(github.event.comment.user.login == 'n0rpan' && github.event.comment.user.type == 'User' &&
(startsWith(github.event.comment.body, '/queue ') || startsWith(github.event.changes.body.from, '/queue ')))))
runs-on: ubuntu-24.04
environment: auto-queue
timeout-minutes: 5
env:
NUMBER: ${{ github.event.pull_request.number || github.event.issue.number || github.event.workflow_run.pull_requests[0].number }}
steps:
# A pull request event already passed the repository test above; it
# needs no lookup, so a failed read cannot stop a push from taking the
# pull request out of line. A comment event does not say which
# repository the branch is in: look that up with the read-only token
# before any step that holds the maintainer's.
- name: Confirm the pull request's branch is in this repository
id: own
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if [ "${GITHUB_EVENT_NAME}" = pull_request_target ]; then
echo "ok=true" >> "${GITHUB_OUTPUT}"
exit 0
fi
head="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${NUMBER}" --jq .head.repo.full_name)"
if [ "${head}" = "${GITHUB_REPOSITORY}" ]; then
echo "ok=true" >> "${GITHUB_OUTPUT}"
else
echo "::notice::#${NUMBER} comes from ${head}; not handled"
fi
# The default ref for both triggers is the base branch, not the pull request.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: steps.own.outputs.ok == 'true'
with:
persist-credentials: false
- name: Apply reviewed queue decision
if: steps.own.outputs.ok == 'true'
env:
GH_TOKEN: ${{ secrets.AUTO_QUEUE_TOKEN }}
MAINTAINER: n0rpan
AUTO_QUEUE_EVENT: ${{ github.event.action }}
AUTO_QUEUE_REASON: ${{ github.event.reason }}
run: |
set -euo pipefail
if [ -z "${GH_TOKEN}" ]; then
echo "::error::AUTO_QUEUE_TOKEN is not set in the main-only auto-queue environment"
exit 1
fi
desktop/ci/auto-queue.sh "${NUMBER}"