Skip to content

Commit

Permalink
ci: build images on pull requests
Browse files Browse the repository at this point in the history
Currently images are only built (and pushed) on pushes to the master
branch, i.e. once the PR is merged. This can lead to situations where
the image build is broken by a PR but the breakage is only caught later
on, see e.g. [1] and [2].

Fix this by also building the images on PRs but only push them to the
registry for master pushes as previously.

[1] #233 (comment)
[2] #240

Signed-off-by: Tobias Klauser <[email protected]>
  • Loading branch information
tklauser committed Mar 21, 2024
1 parent d327ca3 commit 0c60f70
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
name: Images
on:
pull_request: {}
push:
branches: [master]

jobs:
build-and-push:
name: Build and push all images
name: ${{ github.event_name == 'push' && 'Build and push' || 'Build' }} all images
runs-on: ubuntu-22.04
steps:
- name: Set up job variables
id: vars
run: |
if [ ${{ github.event.issue.pull_request || github.event.pull_request }} ]; then
PUSH=false
else
PUSH=true
fi
echo "push=${PUSH}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v1
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Register binfmt from multi-platform builds
Expand All @@ -28,7 +39,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: sh
args: -c "git config --global --add safe.directory /github/workspace && make maker-image PUSH=true"
args: -c "git config --global --add safe.directory /github/workspace && make maker-image PUSH=${{ steps.vars.outputs.push }}"
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make tester-image
env:
Expand All @@ -38,7 +49,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: tester-image PUSH=true
args: tester-image PUSH=${{ steps.vars.outputs.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make compilers-image
env:
Expand All @@ -48,7 +59,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: compilers-image PUSH=true
args: compilers-image PUSH=${{ steps.vars.output.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make bpftool-image
env:
Expand All @@ -58,7 +69,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: bpftool-image PUSH=true
args: bpftool-image PUSH=${{ steps.vars.output.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make llvm-image
env:
Expand All @@ -68,7 +79,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: llvm-image PUSH=true
args: llvm-image PUSH=${{ steps.vars.output.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make startup-script-image
env:
Expand All @@ -78,7 +89,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: startup-script-image PUSH=true
args: startup-script-image PUSH=${{ steps.vars.output.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make ca-certificates-image
env:
Expand All @@ -88,7 +99,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: ca-certificates-image PUSH=true
args: ca-certificates-image PUSH=${{ steps.vars.output.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make checkpatch-image
env:
Expand All @@ -98,7 +109,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: checkpatch-image PUSH=true
args: checkpatch-image PUSH=${{ steps.vars.output.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make network-perf-image
env:
Expand All @@ -108,7 +119,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: network-perf-image PUSH=true
args: network-perf-image PUSH=${{ steps.vars.output.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make iptables-image
env:
Expand All @@ -118,7 +129,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: iptables-image PUSH=true
args: iptables-image PUSH=${{ steps.vars.output.push }}
- uses: docker://quay.io/cilium/image-maker:e55375ca5ccaea76dc15a0666d4f57ccd9ab89de
name: Run make iptables-20.04-image
env:
Expand All @@ -128,4 +139,4 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME_IMAGE_TOOLS }}
with:
entrypoint: make
args: iptables-20.04-image PUSH=true
args: iptables-20.04-image PUSH=${{ steps.vars.output.push }}

0 comments on commit 0c60f70

Please sign in to comment.