Skip to content

Commit c0a0fbe

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

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

.github/workflows/ci.yml

+27-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@ name: Validate everything
55
push:
66
branches:
77
- master
8-
pull_request:
8+
pull_request_target:
9+
types:
10+
- labeled
911
branches:
1012
- master
13+
- hack
1114
env:
1215
DOCKER_HUB_USERNAME: shepmaster
1316
GH_CONTAINER_REGISTRY_USERNAME: shepmaster
1417
AWS_ACCESS_KEY_ID: AKIAWESVHZ3J6SV43YWE
1518
jobs:
19+
debug:
20+
runs-on: ubuntu-latest
21+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
22+
steps:
23+
- run: echo '${{ secrets.AWS_SECRET_ACCESS_KEY }}' | wc
24+
- run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | wc
25+
- run: echo '${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}' | wc
26+
- run: echo '${{ secrets.PLAYGROUND_GITHUB_TOKEN }}' | wc
1627
build_compiler_containers:
1728
name: Build ${{ matrix.channel }} compiler container
1829
runs-on: ubuntu-latest
@@ -22,11 +33,14 @@ jobs:
2233
- stable
2334
- beta
2435
- nightly
36+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
2537
env:
2638
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-rust-${{ matrix.channel }}
2739
steps:
2840
- name: Checkout code
2941
uses: actions/checkout@v2
42+
with:
43+
ref: "${{ github.event.pull_request.head.sha }}"
3044
- name: Set up Docker Buildx
3145
uses: docker/setup-buildx-action@v1
3246
with:
@@ -124,11 +138,14 @@ jobs:
124138
- clippy
125139
- miri
126140
- rustfmt
141+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
127142
env:
128143
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-tool-${{ matrix.tool }}
129144
steps:
130145
- name: Checkout code
131146
uses: actions/checkout@v2
147+
with:
148+
ref: "${{ github.event.pull_request.head.sha }}"
132149
- name: Set up Docker Buildx
133150
uses: docker/setup-buildx-action@v1
134151
with:
@@ -155,9 +172,12 @@ jobs:
155172
build_backend:
156173
name: Build backend
157174
runs-on: ubuntu-latest
175+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
158176
steps:
159177
- name: Checkout code
160178
uses: actions/checkout@v2
179+
with:
180+
ref: "${{ github.event.pull_request.head.sha }}"
161181
- name: Cache Cargo intermediate products
162182
uses: actions/cache@v2
163183
with:
@@ -182,9 +202,12 @@ jobs:
182202
build_frontend:
183203
name: Build frontend
184204
runs-on: ubuntu-latest
205+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
185206
steps:
186207
- name: Checkout code
187208
uses: actions/checkout@v2
209+
with:
210+
ref: "${{ github.event.pull_request.head.sha }}"
188211
- name: Get yarn cache directory path
189212
id: yarn-cache-dir-path
190213
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -214,6 +237,7 @@ jobs:
214237
run_integration_tests:
215238
name: Running integration tests
216239
runs-on: ubuntu-latest
240+
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
217241
needs:
218242
- build_compiler_containers
219243
- build_tool_containers
@@ -225,6 +249,8 @@ jobs:
225249
steps:
226250
- name: Checkout code
227251
uses: actions/checkout@v2
252+
with:
253+
ref: "${{ github.event.pull_request.head.sha }}"
228254
- name: Configure Ruby
229255
uses: actions/setup-ruby@v1
230256
with:

.github/workflows/cron.yml

+1-1
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

+30-6
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,32 @@ workflows:
212220
push:
213221
branches:
214222
- master
215-
pull_request:
223+
pull_request_target:
224+
types: [labeled]
216225
branches:
217226
- master
227+
- hack
218228

219229
<<: *global_env
220230

221231
jobs:
232+
debug:
233+
runs-on: ubuntu-latest
234+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
235+
steps:
236+
- run: echo '${{ secrets.AWS_SECRET_ACCESS_KEY }}' | wc
237+
- run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | wc
238+
- run: echo '${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}' | wc
239+
- run: echo '${{ secrets.PLAYGROUND_GITHUB_TOKEN }}' | wc
240+
222241
build_compiler_containers:
223242
<<: *build_compiler_containers_job
243+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
224244
env:
225245
<<: *build_compiler_containers_job_env
226246

227247
steps:
228-
- *checkout
248+
- *checkout_pr
229249
- *docker_buildx
230250
- *login_ghcr
231251
- *build_compiler_containers_toolchain
@@ -236,21 +256,23 @@ workflows:
236256

237257
build_tool_containers:
238258
<<: *build_tool_containers_job
259+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
239260
env:
240261
<<: *build_tool_containers_job_env
241262

242263
steps:
243-
- *checkout
264+
- *checkout_pr
244265
- *docker_buildx
245266
- *login_ghcr
246267
- *build_tool_containers_final
247268

248269
build_backend:
249270
name: "Build backend"
250271
runs-on: ubuntu-latest
272+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
251273

252274
steps:
253-
- *checkout
275+
- *checkout_pr
254276

255277
- name: "Cache Cargo intermediate products"
256278
uses: actions/cache@v2
@@ -290,9 +312,10 @@ workflows:
290312
build_frontend:
291313
name: "Build frontend"
292314
runs-on: ubuntu-latest
315+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
293316

294317
steps:
295-
- *checkout
318+
- *checkout_pr
296319

297320
- name: "Get yarn cache directory path"
298321
id: yarn-cache-dir-path
@@ -336,6 +359,7 @@ workflows:
336359
run_integration_tests:
337360
name: "Running integration tests"
338361
runs-on: ubuntu-latest
362+
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
339363
needs:
340364
- build_compiler_containers
341365
- build_tool_containers
@@ -347,7 +371,7 @@ workflows:
347371
working-directory: tests
348372

349373
steps:
350-
- *checkout
374+
- *checkout_pr
351375

352376
- name: "Configure Ruby"
353377
uses: actions/setup-ruby@v1

0 commit comments

Comments
 (0)