-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathrelease-manage-runner-groups.yml
More file actions
76 lines (70 loc) · 3.13 KB
/
Copy pathrelease-manage-runner-groups.yml
File metadata and controls
76 lines (70 loc) · 3.13 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
name: Release manage runner groups
on:
workflow_dispatch:
inputs:
apply:
description: "Apply changes (otherwise dry-run)"
type: boolean
default: false
schedule:
# The allow-list pins the newest RC per release line, and RC tags are cut in
# pytorch/pytorch -- which cannot trigger anything in this repo. So the only
# way to notice a new RC is to poll. Without this the allow-list goes stale
# the moment a tag is cut and every release build queues indefinitely, since
# GitHub matches selected_workflows on the exact ref. Off the hour to dodge
# the top-of-hour scheduling backlog.
- cron: "23 * * * *"
push:
branches:
- main
paths:
- tools/scripts/generate_binary_build_matrix.py
# This workflow and its script must redeploy themselves; a change to the
# reconcile logic that never runs is not deployed.
- tools/scripts/release_manage_runner_groups.py
- .github/workflows/release-manage-runner-groups.yml
pull_request:
paths:
- .github/workflows/release-manage-runner-groups.yml
- tools/scripts/release_manage_runner_groups.py
- tools/scripts/generate_binary_build_matrix.py
- tools/tests/test_release_manage_runner_groups.py
permissions:
contents: read
concurrency:
# Not cancel-in-progress: the applying run mutates runner-group config, and
# now that a schedule fires hourly it can collide with a release-time manual
# dispatch. Killing that mid-apply would leave the allow-list half-written.
# Runs are short API calls, so queueing them costs little.
group: release-manage-runner-groups
cancel-in-progress: false
jobs:
reconcile:
runs-on: ubuntu-latest
# The token lives in the protected environment and is only selected on
# main, so PRs and forks never see it and run discovery-only.
environment: ${{ github.ref == 'refs/heads/main' && 'runner-group' || '' }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install dependencies
run: python3 -m pip install requests==2.32.3 PyYAML==6.0.2
- name: Reconcile release runner groups
env:
# Token for managing runner groups, only present in the runner-group
# environment (i.e. on main). Falls back to the default token for
# read-only discovery on PRs.
RUNNER_GROUP_TOKEN: ${{ secrets.RUNNER_GROUP_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
# Apply only from main, and only for a push (matrix or reconcile-logic
# change), the schedule, or an explicit dispatch with apply=true.
# Everything else is a dry-run. The schedule must apply or it would
# poll forever and never act on the new RC it just discovered.
SHOULD_APPLY: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'schedule' || inputs.apply) }}
run: |
SCRIPT=tools/scripts/release_manage_runner_groups.py
if [ "${SHOULD_APPLY}" = "true" ]; then
python3 "${SCRIPT}" --apply
else
python3 "${SCRIPT}"
fi