Skip to content

Commit 30956e1

Browse files
committed
fix(ci): enable e2e for fork PRs via pull_request_target
The local-build approach (single job, no GHCR push) is not feasible because the CI container cannot configure the host Docker daemon's insecure registry list, and container networking prevents access to the local registry on the host loopback. Switch to pull_request_target instead, which runs in the base repo context with write permissions to GHCR. The existing three-job pipeline (build-gateway, build-cluster, e2e) works unchanged. Security: the test:e2e label is a maintainer trust gate — only org members can apply it, signalling the PR code has been reviewed. Add ref input to docker-build.yml and e2e-test.yml so callers can pass github.event.pull_request.head.sha for checkout and image tagging, since github.sha points to the base branch under pull_request_target.
1 parent a69ef06 commit 30956e1

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎.github/workflows/branch-e2e.yml‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: Branch E2E Checks
22

3+
# pull_request_target runs in the base repo context with write permissions,
4+
# enabling fork PRs to push docker images to GHCR and run e2e tests.
5+
# Security: the test:e2e label is a maintainer trust gate — only org members
6+
# can apply it, signalling that the PR code has been reviewed.
37
on:
4-
pull_request:
8+
pull_request_target:
59
types: [opened, synchronize, reopened, labeled]
610

711
permissions:
@@ -16,6 +20,7 @@ jobs:
1620
component: gateway
1721
platform: linux/arm64
1822
runner: build-arm64
23+
ref: ${{ github.event.pull_request.head.sha }}
1924

2025
build-cluster:
2126
if: contains(github.event.pull_request.labels.*.name, 'test:e2e')
@@ -24,10 +29,12 @@ jobs:
2429
component: cluster
2530
platform: linux/arm64
2631
runner: build-arm64
32+
ref: ${{ github.event.pull_request.head.sha }}
2733

2834
e2e:
2935
needs: [build-gateway, build-cluster]
3036
uses: ./.github/workflows/e2e-test.yml
3137
with:
32-
image-tag: ${{ github.sha }}
38+
image-tag: ${{ github.event.pull_request.head.sha }}
3339
runner: build-arm64
40+
ref: ${{ github.event.pull_request.head.sha }}

‎.github/workflows/docker-build.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ on:
3232
required: false
3333
type: string
3434
default: ""
35+
ref:
36+
description: "Git ref to checkout (defaults to the triggering event ref)"
37+
required: false
38+
type: string
39+
default: ""
3540

3641
env:
3742
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -55,14 +60,15 @@ jobs:
5560
volumes:
5661
- /var/run/docker.sock:/var/run/docker.sock
5762
env:
58-
IMAGE_TAG: ${{ github.sha }}
63+
IMAGE_TAG: ${{ inputs.ref || github.sha }}
5964
IMAGE_REGISTRY: ghcr.io/nvidia/openshell
6065
DOCKER_PUSH: ${{ inputs.push && '1' || '0' }}
6166
DOCKER_PLATFORM: ${{ inputs.platform }}
6267
steps:
6368
- uses: actions/checkout@v4
6469
with:
6570
fetch-depth: 0
71+
ref: ${{ inputs.ref || '' }}
6672

6773
- name: Mark workspace safe for git
6874
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

‎.github/workflows/e2e-test.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
required: false
1313
type: string
1414
default: "build-amd64"
15+
ref:
16+
description: "Git ref to checkout (defaults to the triggering event ref)"
17+
required: false
18+
type: string
19+
default: ""
1520

1621
permissions:
1722
contents: read
@@ -40,6 +45,8 @@ jobs:
4045
OPENSHELL_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
4146
steps:
4247
- uses: actions/checkout@v4
48+
with:
49+
ref: ${{ inputs.ref || '' }}
4350

4451
- name: Log in to GHCR
4552
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin

0 commit comments

Comments
 (0)