Skip to content

Commit 31ae3a7

Browse files
committed
Require approval before starting a CI run
1 parent a62f49c commit 31ae3a7

File tree

3 files changed

+56
-8
lines changed

3 files changed

+56
-8
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@ name: Validate everything
55
push:
66
branches:
77
- master
8-
pull_request:
8+
pull_request_target:
9+
types:
10+
- labeled
911
branches:
1012
- master
1113
env:
1214
DOCKER_HUB_USERNAME: shepmaster
1315
GH_CONTAINER_REGISTRY_USERNAME: shepmaster
1416
AWS_ACCESS_KEY_ID: AKIAWESVHZ3J6SV43YWE
1517
jobs:
18+
debug:
19+
runs-on: ubuntu-latest
20+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
21+
steps:
22+
- run: echo '${{ secrets.AWS_SECRET_ACCESS_KEY }}' | wc
23+
- run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | wc
24+
- run: echo '${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}' | wc
25+
- run: echo '${{ secrets.PLAYGROUND_GITHUB_TOKEN }}' | wc
1626
build_compiler_containers:
1727
name: Build ${{ matrix.channel }} compiler container
1828
runs-on: ubuntu-latest
@@ -22,11 +32,14 @@ jobs:
2232
- stable
2333
- beta
2434
- nightly
35+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
2536
env:
2637
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-rust-${{ matrix.channel }}
2738
steps:
2839
- name: Checkout code
2940
uses: actions/checkout@v2
41+
with:
42+
ref: "${{ github.event.pull_request.head.sha }}"
3043
- name: Set up Docker Buildx
3144
uses: docker/setup-buildx-action@v1
3245
with:
@@ -124,11 +137,14 @@ jobs:
124137
- clippy
125138
- miri
126139
- rustfmt
140+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
127141
env:
128142
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-tool-${{ matrix.tool }}
129143
steps:
130144
- name: Checkout code
131145
uses: actions/checkout@v2
146+
with:
147+
ref: "${{ github.event.pull_request.head.sha }}"
132148
- name: Set up Docker Buildx
133149
uses: docker/setup-buildx-action@v1
134150
with:
@@ -155,9 +171,12 @@ jobs:
155171
build_backend:
156172
name: Build backend
157173
runs-on: ubuntu-latest
174+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
158175
steps:
159176
- name: Checkout code
160177
uses: actions/checkout@v2
178+
with:
179+
ref: "${{ github.event.pull_request.head.sha }}"
161180
- name: Cache Cargo intermediate products
162181
uses: actions/cache@v2
163182
with:
@@ -182,9 +201,12 @@ jobs:
182201
build_frontend:
183202
name: Build frontend
184203
runs-on: ubuntu-latest
204+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
185205
steps:
186206
- name: Checkout code
187207
uses: actions/checkout@v2
208+
with:
209+
ref: "${{ github.event.pull_request.head.sha }}"
188210
- name: Get yarn cache directory path
189211
id: yarn-cache-dir-path
190212
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -214,6 +236,7 @@ jobs:
214236
run_integration_tests:
215237
name: Running integration tests
216238
runs-on: ubuntu-latest
239+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
217240
needs:
218241
- build_compiler_containers
219242
- build_tool_containers
@@ -225,6 +248,8 @@ jobs:
225248
steps:
226249
- name: Checkout code
227250
uses: actions/checkout@v2
251+
with:
252+
ref: "${{ github.event.pull_request.head.sha }}"
228253
- name: Configure Ruby
229254
uses: actions/setup-ruby@v1
230255
with:

.github/workflows/cron.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
---
33
name: Scheduled rebuild
44
'on':
5-
workflow_dispatch:
5+
workflow_dispatch:
66
schedule:
77
- cron: 7 2 * * *
88
env:

ci/workflows.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ components:
99
name: "Checkout code"
1010
uses: actions/checkout@v2
1111

12+
# This should only be used when we know that the code being tested
13+
# doesn't make use of our secrets or elevated GitHub token.
14+
- checkout_pr: &checkout_pr
15+
name: "Checkout code"
16+
uses: actions/checkout@v2
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
1220
- docker_buildx: &docker_buildx
1321
name: "Set up Docker Buildx"
1422
uses: docker/setup-buildx-action@v1
@@ -212,20 +220,31 @@ workflows:
212220
push:
213221
branches:
214222
- master
215-
pull_request:
223+
pull_request_target:
224+
types: [labeled]
216225
branches:
217226
- master
218227

219228
<<: *global_env
220229

221230
jobs:
231+
debug:
232+
runs-on: ubuntu-latest
233+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
234+
steps:
235+
- run: echo '${{ secrets.AWS_SECRET_ACCESS_KEY }}' | wc
236+
- run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | wc
237+
- run: echo '${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}' | wc
238+
- run: echo '${{ secrets.PLAYGROUND_GITHUB_TOKEN }}' | wc
239+
222240
build_compiler_containers:
223241
<<: *build_compiler_containers_job
242+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
224243
env:
225244
<<: *build_compiler_containers_job_env
226245

227246
steps:
228-
- *checkout
247+
- *checkout_pr
229248
- *docker_buildx
230249
- *login_ghcr
231250
- *build_compiler_containers_toolchain
@@ -236,21 +255,23 @@ workflows:
236255

237256
build_tool_containers:
238257
<<: *build_tool_containers_job
258+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
239259
env:
240260
<<: *build_tool_containers_job_env
241261

242262
steps:
243-
- *checkout
263+
- *checkout_pr
244264
- *docker_buildx
245265
- *login_ghcr
246266
- *build_tool_containers_final
247267

248268
build_backend:
249269
name: "Build backend"
250270
runs-on: ubuntu-latest
271+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
251272

252273
steps:
253-
- *checkout
274+
- *checkout_pr
254275

255276
- name: "Cache Cargo intermediate products"
256277
uses: actions/cache@v2
@@ -290,9 +311,10 @@ workflows:
290311
build_frontend:
291312
name: "Build frontend"
292313
runs-on: ubuntu-latest
314+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
293315

294316
steps:
295-
- *checkout
317+
- *checkout_pr
296318

297319
- name: "Get yarn cache directory path"
298320
id: yarn-cache-dir-path
@@ -336,6 +358,7 @@ workflows:
336358
run_integration_tests:
337359
name: "Running integration tests"
338360
runs-on: ubuntu-latest
361+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
339362
needs:
340363
- build_compiler_containers
341364
- build_tool_containers
@@ -347,7 +370,7 @@ workflows:
347370
working-directory: tests
348371

349372
steps:
350-
- *checkout
373+
- *checkout_pr
351374

352375
- name: "Configure Ruby"
353376
uses: actions/setup-ruby@v1

0 commit comments

Comments
 (0)