Skip to content

Commit c0fe295

Browse files
Add new build-container workflow for PRs (#198)
* Add new build-container workflow for PRs Signed-off-by: Jose Castillo Lema <[email protected]> * Unify in one workflow Signed-off-by: Jose Castillo Lema <[email protected]> * Update description Signed-off-by: Jose Castillo Lema <[email protected]> * Removing the gha-build dependency from gha-push Signed-off-by: Jose Castillo Lema <[email protected]> * Differentiate job names Signed-off-by: Jose Castillo Lema <[email protected]> * Remove double quotes Signed-off-by: Jose Castillo Lema <[email protected]> * only run push in main branch Signed-off-by: Jose Castillo Lema <[email protected]> --------- Signed-off-by: Jose Castillo Lema <[email protected]>
1 parent f0a857d commit c0fe295

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

.github/workflows/build-container.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
name: Release k8s-netperf container image
1+
name: Build k8s-netperf container image
22

33
on:
4+
pull_request:
5+
branches: [ "*" ]
6+
paths:
7+
- "containers/**" # Trigger only when Dockerfile changes in a pull request
48
push:
9+
branches: [ main ]
510
paths:
611
- "containers/**" # Trigger only when Dockerfile changes in a pull request
712

@@ -18,7 +23,7 @@ jobs:
1823
permissions:
1924
contents: read
2025
packages: write
21-
26+
2227
steps:
2328
- name: Setup QEMU & Install Dependecies
2429
run: |
@@ -35,13 +40,20 @@ jobs:
3540
with:
3641
go-version: ${{ env.GO_VER }}
3742

38-
- name: Build and Push multi-arch Image
39-
id: push
43+
- name: Build multi-arch Image
44+
id: build
4045
run: |
4146
make build
42-
podman login quay.io -u ${QUAY_USER} -p ${QUAY_TOKEN}
43-
make gha-push
47+
make gha-build
4448
env:
4549
GO_VER: ${{ env.GO_VER }}
50+
51+
- name: Push multi-arch Image
52+
id: push
53+
if: github.event_name == 'push'
54+
run: |
55+
podman login ${{ env.CONTAINER_REGISTRY }} -u ${QUAY_USER} -p ${QUAY_TOKEN}
56+
make gha-push
57+
env:
4658
QUAY_USER: ${{ secrets.QUAY_USER }}
47-
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
59+
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ gha-build:
4646
--build-arg RHEL_VERSION=$(RHEL_VERSION) --platform=linux/amd64,linux/arm64,linux/ppc64le,linux/s390x \
4747
./containers --manifest=$(CONTAINER_NS)/${BIN}:latest
4848

49-
gha-push: gha-build
49+
gha-push:
5050
@echo "Pushing Container Images & manifest"
5151
$(CONTAINER) manifest push $(CONTAINER_NS)/${BIN}:latest $(CONTAINER_NS)/${BIN}:latest
5252

0 commit comments

Comments
 (0)