Skip to content

Commit 4077274

Browse files
committed
.github: allow fork PR checkout in v1.20 build-images workflows
Follow-up to f7fe2d2 (cilium#47133), which added allow-unsafe-pr-checkout to the build-images pull_request_target workflows for the "", v1.17, v1.18 and v1.19 variants but missed the v1.20 ones. build-images-{base,ci,docs-builder}-v1.20 are the pull_request_target entry workflows for v1.20 PRs (they live on main, read from the default branch). Without the flag, checkout v7 refuses to fetch fork PR head code and the image builds break for PRs opened from forks. Set allow-unsafe-pr-checkout: true on the NOT TRUSTED checkouts and bump the checkout pin to v7.0.0, matching the rest of cilium#47133. This commit was prepared with AIL:3. Signed-off-by: André Martins <andre@cilium.io>
1 parent 424f14c commit 4077274

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

.github/workflows/build-images-base-v1.20.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ubuntu-24.04
4040
steps:
4141
- name: Checkout base or default branch (trusted)
42-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
42+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
4343
with:
4444
# This workflow is supposed to run only on pull_request_target context, but in case workflow call is made from a push context we still keep the default to default_branch
4545
ref: ${{ github.base_ref || github.event.repository.default_branch }}
@@ -76,9 +76,11 @@ jobs:
7676
# Warning: since this is a privileged workflow, subsequent workflow job
7777
# steps must take care not to execute untrusted code.
7878
- name: Checkout pull request branch (NOT TRUSTED)
79-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
79+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
8080
with:
8181
persist-credentials: false
82+
# Required by checkout v7+ to fetch fork PR code; see the NOT TRUSTED warning above.
83+
allow-unsafe-pr-checkout: true
8284
ref: ${{ github.event.pull_request.head.sha }}
8385

8486
- name: Set-up git

.github/workflows/build-images-ci-v1.20.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686

8787
steps:
8888
- name: Checkout base or default branch (trusted)
89-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
89+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
9090
with:
9191
# We first check if base_ref exist, meaning we're in pull_request_target context, and if not we just use default_branch
9292
ref: ${{ github.base_ref || github.event.repository.default_branch }}
@@ -187,9 +187,11 @@ jobs:
187187
# Warning: since this is a privileged workflow, subsequent workflow job
188188
# steps must take care not to execute untrusted code.
189189
- name: Checkout pull request branch (NOT TRUSTED)
190-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
190+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
191191
with:
192192
persist-credentials: false
193+
# Required by checkout v7+ to fetch fork PR code; see the NOT TRUSTED warning above.
194+
allow-unsafe-pr-checkout: true
193195
ref: ${{ steps.tag.outputs.sha }}
194196

195197
- name: Check for disk usage

.github/workflows/build-images-docs-builder-v1.20.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
digest: ${{ steps.docker-build-docs-builder.outputs.digest }}
3636
steps:
3737
- name: Checkout base branch (trusted)
38-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
38+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
3939
with:
4040
ref: ${{ github.base_ref }}
4141
persist-credentials: false
@@ -52,9 +52,11 @@ jobs:
5252
# Warning: since this is a privileged workflow, subsequent workflow job
5353
# steps must take care not to execute untrusted code.
5454
- name: Checkout pull request branch (NOT TRUSTED)
55-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
55+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
5656
with:
5757
persist-credentials: false
58+
# Required by checkout v7+ to fetch fork PR code; see the NOT TRUSTED warning above.
59+
allow-unsafe-pr-checkout: true
5860
ref: ${{ github.event.pull_request.head.sha }}
5961

6062
- name: Generate image tag for docs-builder
@@ -106,7 +108,7 @@ jobs:
106108
timeout-minutes: 10
107109
steps:
108110
- name: Checkout base branch (trusted)
109-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
111+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
110112
with:
111113
ref: ${{ github.base_ref }}
112114
persist-credentials: false
@@ -117,9 +119,11 @@ jobs:
117119
# Warning: since this is a privileged workflow, subsequent workflow job
118120
# steps must take care not to execute untrusted code.
119121
- name: Checkout pull request branch (NOT TRUSTED)
120-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
122+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
121123
with:
122124
persist-credentials: false
125+
# Required by checkout v7+ to fetch fork PR code; see the NOT TRUSTED warning above.
126+
allow-unsafe-pr-checkout: true
123127
ref: ${{ github.event.pull_request.head.sha }}
124128

125129
- name: Set up git
@@ -159,9 +163,11 @@ jobs:
159163
deployment: false
160164
steps:
161165
- name: Checkout pull request branch (NOT TRUSTED)
162-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
166+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
163167
with:
164168
persist-credentials: false
169+
# Required by checkout v7+ to fetch fork PR code; see the NOT TRUSTED warning above.
170+
allow-unsafe-pr-checkout: true
165171
ref: ${{ github.event.pull_request.head.sha }}
166172

167173
- name: Set up git
@@ -200,7 +206,7 @@ jobs:
200206
timeout-minutes: 10
201207
steps:
202208
- name: Checkout base branch (trusted)
203-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
209+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
204210
with:
205211
ref: ${{ github.base_ref }}
206212
persist-credentials: false

0 commit comments

Comments
 (0)