Repository navigation
98 lines (93 loc) · 3.8 KB
/
Copy pathcontroller.yml
File metadata and controls
98 lines (93 loc) · 3.8 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
88
89
90
91
92
93
94
95
96
97
98
name: controller
# A deterministic, label-only controller (AGENTS.md › Controller): no LLM, no
# secrets, only the built-in GITHUB_TOKEN. It never merges, approves, comments
# on or closes anything and never checks out or runs a PR or issue: their text
# is data for a regex, the changed files are read through the API. Script and
# rules come from the default branch.
#
# Switches (repository variables):
# CONTROLLER_LIVE exactly `true` -> the `apply` job writes labels; anything
# else -> dry run, the plan goes to the job summary.
# AGENT_PAUSE `true` -> kill switch: nothing is read, proposed or changed.
# To turn it off entirely, disable this workflow in the Actions tab.
#
# It also runs on the three PR lifecycle events, so a new PR is labelled now
# rather than at the next cron tick. The old half-hourly schedule declared 48
# slots a day and in practice ran twice (2026-11-19: 3 runs; 2026-11-20: 2),
# so immediacy comes from these events and manual dispatch, and the cron is a
# four-a-day backstop only. A `pull_request` run from a fork head carries a
# read-only token, so both jobs skip it: the fallback cron still labels fork PRs.
#
# The demotion half is the safety-critical one and it had no event at all: a
# label set by a non-maintainer, or an edit after the approval, was only read at
# the next tick. The schedule skipped 14 h 16 min once (19 Nov 18:10 -> 20 Nov
# 08:26 UTC), and for that whole window an approval someone had just voided was
# still usable. So `issues` `labeled` / `unlabeled` / `edited` wake it too. The
# run the controller's own removal triggers plans nothing, so this cannot loop.
on:
pull_request:
types: [opened, ready_for_review, reopened]
issues:
types: [labeled, unlabeled, edited]
schedule:
- cron: '17 */6 * * *'
workflow_dispatch:
concurrency:
group: controller
cancel-in-progress: false
permissions: {}
jobs:
plan:
name: plan (read only)
runs-on: ubuntu-latest
timeout-minutes: 10
# A read-only token is all this job needs, but a fork head's run must not
# hand `apply` a live plan, so it is skipped like `apply` is.
if: >-
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
issues: read
pull-requests: read
outputs:
live: ${{ steps.plan.outputs.live }}
plan: ${{ steps.plan.outputs.plan }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
- id: plan
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
CONTROLLER_LIVE: ${{ vars.CONTROLLER_LIVE }}
AGENT_PAUSE: ${{ vars.AGENT_PAUSE }}
run: python3 .github/scripts/controller.py plan
apply:
name: apply labels (live only)
needs: plan
if: >-
needs.plan.outputs.live == 'true' && vars.CONTROLLER_LIVE == 'true'
&& vars.AGENT_PAUSE != 'true'
&& (github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
issues: write
pull-requests: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
- env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
CONTROLLER_LIVE: ${{ vars.CONTROLLER_LIVE }}
AGENT_PAUSE: ${{ vars.AGENT_PAUSE }}
PLAN: ${{ needs.plan.outputs.plan }}
run: python3 .github/scripts/controller.py apply