Skip to content

Commit 27d934c

Browse files
committed
[GHA] Fix e2e workflow for forks
This follows on from #1722 which set the `pull-request: write` permission on for the e2e workflows. However, this did not fully resolve the 403 issue, see [1], [2], and [3]. Those jobs have the following token permissions: ``` GITHUB_TOKEN Permissions Contents: read Metadata: read PullRequests: read ``` After some digging, I found a [post](https://stackoverflow.com/a/78444521) which notes that using the `pull_request` workflow trigger will never grant write permissions when the pull request comes from a public fork. The solution is to instead use the `pull_request_target` trigger, I found this [post](https://stackoverflow.com/a/74959635) helpful reading on the trade-offs of using this trigger. The main difference, other than allowing write permissions, is that the workflow config used comes from the pull request's base branch so does not include any workflow changes from the pull request. As such, in this patch I've split out the e2e workflows from our main build & test workflow to restrict the scope of jobs which may be granted write permissions. [1]: https://github.com/oneapi-src/unified-runtime/actions/runs/9417159892/job/25942801242?pr=1639 [2]: https://github.com/oneapi-src/unified-runtime/actions/runs/9417159892/job/25942802400?pr=1639 [3]: https://github.com/oneapi-src/unified-runtime/actions/runs/9417159892/job/25942803189?pr=1639
1 parent 963b013 commit 27d934c

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

.github/workflows/cmake.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ concurrency:
88

99
permissions:
1010
contents: read
11-
pull-requests: write
1211

1312
jobs:
1413
ubuntu-build:
@@ -192,30 +191,6 @@ jobs:
192191
with:
193192
name: NATIVE_CPU
194193

195-
e2e-level-zero:
196-
name: E2E L0
197-
permissions:
198-
contents: read
199-
pull-requests: write
200-
needs: [ubuntu-build, level-zero]
201-
uses: ./.github/workflows/e2e_level_zero.yml
202-
203-
e2e-opencl:
204-
name: E2E OpenCL
205-
permissions:
206-
contents: read
207-
pull-requests: write
208-
needs: [ubuntu-build, opencl]
209-
uses: ./.github/workflows/e2e_opencl.yml
210-
211-
e2e-cuda:
212-
name: E2E CUDA
213-
permissions:
214-
contents: read
215-
pull-requests: write
216-
needs: [ubuntu-build, cuda]
217-
uses: ./.github/workflows/e2e_cuda.yml
218-
219194
windows-build:
220195
name: Build - Windows
221196
strategy:

.github/workflows/e2e.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: SYCL E2E
3+
4+
# The e2e workflow adds a comment to the pull request in the final step which
5+
# requires the pull-request: write permission.
6+
# When a pull request originates from a fork using the pull_request trigger
7+
# will never grant write permissions due to security concerns.
8+
# Instead, the pull_request_target trigger is necessary to be granted the
9+
# pull-request: write permission.
10+
on: [push, pull_request_target]
11+
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
jobs:
17+
e2e-level-zero:
18+
name: E2E L0
19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
needs: [ubuntu-build, level-zero]
23+
uses: ./.github/workflows/e2e_level_zero.yml
24+
25+
e2e-opencl:
26+
name: E2E OpenCL
27+
permissions:
28+
contents: read
29+
pull-requests: write
30+
needs: [ubuntu-build, opencl]
31+
uses: ./.github/workflows/e2e_opencl.yml
32+
33+
e2e-cuda:
34+
name: E2E CUDA
35+
permissions:
36+
contents: read
37+
pull-requests: write
38+
needs: [ubuntu-build, cuda]
39+
uses: ./.github/workflows/e2e_cuda.yml

0 commit comments

Comments
 (0)