Skip to content

Commit 5ff35da

Browse files
authored
Provide better experience for forked PRs (#653)
Ensure the workflows `test-deployment.yaml` and `build.yaml` work on a forked PR.
1 parent e8a7d0b commit 5ff35da

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

.github/workflows/build.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,18 @@ permissions:
1212
contents: read
1313

1414
jobs:
15+
setup:
16+
if: github.event_name == 'pull_request'
17+
outputs:
18+
is_fork: ${{ steps.fork.outputs.is_fork }}
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Identify if the PR comes from a fork
23+
id: fork
24+
run: echo "is_fork=$(gh pr view --json isCrossRepository --jq .isCrossRepository)" >> $GITHUB_OUTPUT
1525
docker-build:
26+
needs: setup
1627
permissions:
1728
contents: read
1829
packages: write
@@ -21,3 +32,4 @@ jobs:
2132
name: runner-manager
2233
namespace: ${{ github.repository_owner }}
2334
tag: ${{ github.ref_name == 'main' && 'latest' || github.sha }}
35+
push: ${{ needs.setup.outputs.is_fork == 'true' && false || true }}

.github/workflows/test-deployment.yaml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,31 @@ permissions:
88
packages: write
99

1010
jobs:
11-
docker-build:
12-
permissions:
13-
contents: write
14-
packages: write
15-
uses: scality/workflows/.github/workflows/docker-build.yaml@v2
16-
with:
17-
name: runner-manager
18-
namespace: ${{ github.repository_owner }}
19-
2011
test-deployment:
21-
needs: docker-build
2212
runs-on: ubuntu-latest
2313
steps:
2414
- uses: actions/checkout@v4
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v3
17+
- name: Build runner-manager image
18+
uses: docker/build-push-action@v5
19+
with:
20+
context: .
21+
push: false
22+
load: true
23+
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
24+
cache-from: type=gha,scope=runner-manager
25+
cache-to: type=gha,mode=max,scope=runner-manager
2526
- uses: helm/kind-action@v1
27+
with:
28+
cluster_name: kind
29+
- name: Wait for kind node to be ready
30+
run: kubectl wait --for=condition=Ready node/kind-control-plane --timeout=120s
31+
- name: Load image to kind cluster
32+
run: kind load docker-image ghcr.io/${{ github.repository }}:${{ github.sha }}
2633
- name: Edit the runner-manager image
2734
working-directory: manifests
28-
run: kustomize edit set image ghcr.io/${{ github.repository_owner }}/runner-manager:${{ github.sha }}
35+
run: kustomize edit set image ghcr.io/${{ github.repository }}:${{ github.sha }}
2936
- name: Deploy runner-manager
3037
run: kubectl apply -k manifests
3138
- name: Check if deployment is ready

0 commit comments

Comments
 (0)