Skip to content

Commit 59672c4

Browse files
authored
Route trusted Linux builds to managed runners (#1270)
Same-repository pull-request branches are controlled by repository collaborators and should use organization-managed Linux capacity. Fork pull requests remain arbitrary code—even when the author is an organization member—and must continue to use GitHub-hosted runners. Each PR now triggers only `pull_request`, so required checks are associated with the current PR revision. The dispatcher calls a main-pinned reusable workflow, and that immutable workflow independently requires both the head and base repositories to equal `github.repository` before selecting the managed public fleet. The caller supplies no runner or trust input. The organization runner policy restricts access to the exact main-branch reusable workflows. Main pushes use the managed Linux fleet; Windows, macOS, ARM Linux, tags, and fork PRs retain their hosted runners. Co-authored-by: Wes McKinney <wesm@users.noreply.github.com>
1 parent 285bfa3 commit 59672c4

7 files changed

Lines changed: 109 additions & 37 deletions

File tree

.github/workflows/bench-pr.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Bench Gate
2+
3+
# The PR dispatcher always calls the main-pinned workflow. That workflow
4+
# independently routes same-repository Linux jobs to the managed public fleet
5+
# and fork jobs to GitHub-hosted runners.
6+
on:
7+
pull_request:
8+
# Docs/frontend-only PRs cannot change the gated Go paths. If
9+
# this check is ever made required on branch protection, pair it
10+
# with a no-op sibling workflow on the inverse paths.
11+
paths:
12+
- "**.go"
13+
- "go.mod"
14+
- "go.sum"
15+
- "Makefile"
16+
- ".github/workflows/bench.yml"
17+
- ".github/workflows/bench-pr.yml"
18+
permissions: read-all
19+
20+
jobs:
21+
run:
22+
uses: kenn-io/agentsview/.github/workflows/bench.yml@main
23+
with:
24+
checkout_ref: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/bench.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,13 @@ name: Bench Gate
2828
# produced still gate) rather than silently disabling the whole gate.
2929

3030
on:
31-
pull_request:
32-
# Docs/frontend-only PRs cannot change the gated Go paths. If
33-
# this check is ever made required on branch protection, pair it
34-
# with a no-op sibling workflow on the inverse paths.
35-
paths:
36-
- "**.go"
37-
- "go.mod"
38-
- "go.sum"
39-
- "Makefile"
40-
- ".github/workflows/bench.yml"
41-
31+
workflow_call:
32+
inputs:
33+
checkout_ref:
34+
description: Git ref to check out
35+
required: false
36+
type: string
37+
default: ""
4238
concurrency:
4339
group: bench-${{ github.head_ref || github.ref }}
4440
cancel-in-progress: true
@@ -49,10 +45,11 @@ permissions:
4945
jobs:
5046
bench-gate:
5147
name: Benchmark Gate
52-
runs-on: ubuntu-latest
48+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
5349
steps:
5450
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
5551
with:
52+
ref: ${{ inputs.checkout_ref || github.sha }}
5653
persist-credentials: false
5754
fetch-depth: 0
5855

.github/workflows/ci-pr.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
3+
# The PR dispatcher always calls the main-pinned workflow. That workflow
4+
# independently routes same-repository Linux jobs to the managed public fleet
5+
# and fork jobs to GitHub-hosted runners.
6+
on:
7+
pull_request:
8+
9+
permissions: read-all
10+
11+
jobs:
12+
run:
13+
uses: kenn-io/agentsview/.github/workflows/ci.yml@main
14+
with:
15+
checkout_ref: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/ci.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
name: CI
22

33
on:
4+
workflow_call:
5+
inputs:
6+
checkout_ref:
7+
description: Git ref to check out
8+
required: false
9+
type: string
10+
default: ""
411
push:
512
branches: [main]
613
# Run on every pull request regardless of base branch so stacked PRs that
714
# target another feature branch (not just main) still get the full test,
815
# lint, and e2e suite. The expensive desktop/tauri bundle builds are gated
916
# to main separately in desktop-artifacts.yml.
10-
pull_request:
11-
1217
concurrency:
1318
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
1419
cancel-in-progress: true
@@ -18,10 +23,11 @@ permissions:
1823

1924
jobs:
2025
lint:
21-
runs-on: ubuntu-latest
26+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
2227
steps:
2328
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
2429
with:
30+
ref: ${{ inputs.checkout_ref || github.sha }}
2531
persist-credentials: false
2632

2733
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
@@ -37,10 +43,11 @@ jobs:
3743
run: make lint-ci
3844

3945
frontend:
40-
runs-on: ubuntu-latest
46+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
4147
steps:
4248
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
4349
with:
50+
ref: ${{ inputs.checkout_ref || github.sha }}
4451
persist-credentials: false
4552

4653
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -67,10 +74,11 @@ jobs:
6774
working-directory: frontend
6875

6976
frontend-node-25:
70-
runs-on: ubuntu-latest
77+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
7178
steps:
7279
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
7380
with:
81+
ref: ${{ inputs.checkout_ref || github.sha }}
7482
persist-credentials: false
7583

7684
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -86,10 +94,11 @@ jobs:
8694
working-directory: frontend
8795

8896
docs:
89-
runs-on: ubuntu-latest
97+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
9098
steps:
9199
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
92100
with:
101+
ref: ${{ inputs.checkout_ref || github.sha }}
93102
persist-credentials: false
94103

95104
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
@@ -108,10 +117,11 @@ jobs:
108117
run: make docs-check
109118

110119
scripts:
111-
runs-on: ubuntu-latest
120+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
112121
steps:
113122
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
114123
with:
124+
ref: ${{ inputs.checkout_ref || github.sha }}
115125
persist-credentials: false
116126

117127
- name: Run shell script tests
@@ -124,14 +134,15 @@ jobs:
124134
125135
test:
126136
name: Go Test (${{ matrix.os }})
127-
runs-on: ${{ matrix.os }}
137+
runs-on: ${{ contains(fromJSON('["ubuntu-latest","ubuntu-24.04","ubuntu-22.04"]'), matrix.os) && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || matrix.os }}
128138
strategy:
129139
fail-fast: false
130140
matrix:
131141
os: [ubuntu-latest, windows-latest]
132142
steps:
133143
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
134144
with:
145+
ref: ${{ inputs.checkout_ref || github.sha }}
135146
fetch-depth: 0
136147
persist-credentials: false
137148

@@ -185,6 +196,7 @@ jobs:
185196
steps:
186197
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
187198
with:
199+
ref: ${{ inputs.checkout_ref || github.sha }}
188200
persist-credentials: false
189201

190202
- name: Prepare placeholder sidecar resource
@@ -215,10 +227,11 @@ jobs:
215227
run: cargo test --locked --manifest-path desktop/src-tauri/Cargo.toml --lib install_downloaded_update
216228

217229
coverage:
218-
runs-on: ubuntu-latest
230+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
219231
steps:
220232
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
221233
with:
234+
ref: ${{ inputs.checkout_ref || github.sha }}
222235
fetch-depth: 0
223236
persist-credentials: false
224237

@@ -246,7 +259,7 @@ jobs:
246259
run: echo "::warning::Codecov upload failed"
247260

248261
integration:
249-
runs-on: ubuntu-latest
262+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
250263
services:
251264
postgres:
252265
image: pgvector/pgvector:pg18
@@ -264,6 +277,7 @@ jobs:
264277
steps:
265278
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
266279
with:
280+
ref: ${{ inputs.checkout_ref || github.sha }}
267281
fetch-depth: 0
268282
persist-credentials: false
269283

@@ -312,10 +326,11 @@ jobs:
312326
TEST_SSH_KEY: ${{ github.workspace }}/testdata/ssh/test_key
313327

314328
e2e:
315-
runs-on: ubuntu-latest
329+
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
316330
steps:
317331
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
318332
with:
333+
ref: ${{ inputs.checkout_ref || github.sha }}
319334
fetch-depth: 0
320335
persist-credentials: false
321336

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Desktop Artifacts
2+
3+
# The PR dispatcher always calls the main-pinned workflow. That workflow
4+
# independently routes same-repository Linux jobs to the managed public fleet
5+
# and fork jobs to GitHub-hosted runners.
6+
on:
7+
pull_request:
8+
branches: [main]
9+
paths:
10+
- 'desktop/**'
11+
- 'frontend/**'
12+
- 'go.mod'
13+
- 'go.sum'
14+
- '.github/workflows/desktop-artifacts.yml'
15+
- '.github/actions/build-desktop-artifact/**'
16+
- '.github/workflows/desktop-artifacts-pr.yml'
17+
permissions: read-all
18+
19+
jobs:
20+
run:
21+
uses: kenn-io/agentsview/.github/workflows/desktop-artifacts.yml@main
22+
with:
23+
checkout_ref: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/desktop-artifacts.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: Desktop Artifacts
22

33
on:
4-
# Keep this workflow GitHub-hosted so pull requests cannot select a
5-
# persistent runner. macOS builds live in desktop-macos-main.yml.
4+
workflow_call:
5+
inputs:
6+
checkout_ref:
7+
description: Git ref to check out
8+
required: false
9+
type: string
10+
default: ""
11+
# Linux builds use the managed public fleet for main and same-repository PRs.
12+
# macOS builds live in desktop-macos-main.yml.
613
push:
714
branches: [main]
815
paths:
@@ -12,16 +19,6 @@ on:
1219
- 'go.sum'
1320
- '.github/workflows/desktop-artifacts.yml'
1421
- '.github/actions/build-desktop-artifact/**'
15-
pull_request:
16-
branches: [main]
17-
paths:
18-
- 'desktop/**'
19-
- 'frontend/**'
20-
- 'go.mod'
21-
- 'go.sum'
22-
- '.github/workflows/desktop-artifacts.yml'
23-
- '.github/actions/build-desktop-artifact/**'
24-
2522
permissions:
2623
contents: read
2724

@@ -32,7 +29,7 @@ concurrency:
3229
jobs:
3330
build:
3431
name: Desktop Build (${{ matrix.name }})
35-
runs-on: ${{ matrix.os }}
32+
runs-on: ${{ contains(fromJSON('["ubuntu-latest","ubuntu-24.04","ubuntu-22.04"]'), matrix.os) && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || matrix.os }}
3633
strategy:
3734
fail-fast: false
3835
matrix:
@@ -58,6 +55,7 @@ jobs:
5855
steps:
5956
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
6057
with:
58+
ref: ${{ inputs.checkout_ref || github.sha }}
6159
persist-credentials: false
6260

6361
- uses: ./.github/actions/build-desktop-artifact

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616

1717
jobs:
1818
build-and-push:
19-
runs-on: ubuntu-latest
19+
runs-on: ${{ github.ref == 'refs/heads/main' && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
2020
steps:
2121
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
2222
with:

0 commit comments

Comments
 (0)