Skip to content

Commit 4e2610d

Browse files
committed
chore: prevent unauthed PR runs
1 parent f9b4dde commit 4e2610d

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

.github/workflows/build.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: build
22
on:
33
workflow_call:
44
inputs:
5+
ref:
6+
required: false
7+
type: string
8+
default: ""
59
push-image:
610
required: false
711
type: boolean
@@ -21,6 +25,8 @@ jobs:
2125
packages: write
2226
steps:
2327
- uses: actions/checkout@v4
28+
with:
29+
ref: ${{ inputs.ref || github.ref }}
2430
- uses: nixbuild/nix-quick-install-action@v34
2531
with:
2632
nix_conf: |

.github/workflows/pr-unlabel.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: pr-unlabel
2+
on:
3+
pull_request_target:
4+
types: [synchronize]
5+
branches:
6+
- main
7+
jobs:
8+
remove-safe-label:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Remove safe-to-build label
12+
run: gh pr edit ${{ github.event.pull_request.number }} --remove-label "safe-to-build" --repo ${{ github.repository }}
13+
env:
14+
GH_TOKEN: ${{ github.token }}
15+
continue-on-error: true

.github/workflows/pr.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: pr
22
on:
3-
pull_request:
3+
pull_request_target:
4+
types: [labeled]
45
branches:
56
- main
67
jobs:
78
check-pr:
9+
if: github.event.label.name == 'safe-to-build'
810
uses: ./.github/workflows/build.yaml
911
with:
12+
ref: ${{ github.event.pull_request.head.sha }}
1013
push-image: false
1114
create-release: false

0 commit comments

Comments
 (0)