Skip to content

Commit

Permalink
chore(ci): fix main build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Jun 19, 2024
1 parent 699c197 commit ed5af8a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 58 deletions.
55 changes: 9 additions & 46 deletions .github/workflows/__build-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,49 +225,9 @@ jobs:
# Ref: https://docs.docker.com/build/ci/github-actions/test-before-push/
outputs: ${{ !inputs.push && 'type=docker,dest=/tmp/image.tar' }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: image-${{ matrix.os }}-${{ matrix.arch }}
path: /tmp/image.tar

test-image:
name: Run image to verify it and check -version output
runs-on: ubuntu-latest
needs:
- semver
- build

strategy:
# Whatever gets changed here should be changed in the multi-arch job below.
matrix:
include:
- os: linux
arch: amd64
- os: linux
arch: arm64

steps:
- uses: actions/checkout@v4

- name: Download artifact with built image
uses: actions/download-artifact@v4
with:
name: image-${{ matrix.os }}-${{ matrix.arch }}
path: /tmp/${{ matrix.os }}/${{ matrix.arch }}/

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.arch }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Load image
run: |
docker load --input /tmp/${{ matrix.os }}/${{ matrix.arch }}/image.tar
docker image ls -a

- name: Test the image by running it with -version flag
# NOTE: we can't use steps.build.outputs.tags here because it's there's more than one tag
Expand All @@ -276,10 +236,15 @@ jobs:
# reference ${{ inputs.image-name }}.
run: |
docker images
docker images --format {{.ID}} --filter reference=${{ inputs.image-name }} | xargs -I {} \
docker run --rm \
docker run --rm \
--platform ${{ matrix.os }}/${{ matrix.arch }} \
{} -version | ${{ inputs.verify-image-script }} ${{ github.repository }}
${{ inputs.image-name }}:${{ steps.meta.outputs.version }} -version | ${{ inputs.verify-image-script }} ${{ github.repository }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: image-${{ matrix.os }}-${{ matrix.arch }}
path: /tmp/image.tar

build-multi-arch:
name: Build and push multi-arch manifest
Expand All @@ -292,14 +257,12 @@ jobs:
needs:
- semver
- build
- test-image

steps:
- uses: actions/checkout@v4

- name: Configure Git for private repositories (this is needed by repositories that include this workflow and have other private dependencies)
run: git config --global url."https://${{ secrets.gh-pat }}@github.com".insteadOf "https://github.com"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
push:
branches:
- 'main'
pull_request:
branches:
- '*'
workflow_dispatch: {}

jobs:
Expand All @@ -26,4 +29,6 @@ jobs:
username: ${{ vars.DOCKERHUB_PUSH_USERNAME }}
registry: docker.io
image-name: ${{ vars.DOCKERHUB_IMAGE_NAME }}
push: true
# If we pushed then it means we want to build and push the image.
# Branch filter above will decide pushes to which branch will trigger this.
push: ${{ github.event.action == 'push' }}
11 changes: 0 additions & 11 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,6 @@ jobs:
- name: Verify that uninstalling operator CRDs via kustomize works
run: make uninstall

build-image:
uses: ./.github/workflows/__build-workflow.yaml
secrets:
dockerhub-token: ${{ secrets.DOCKERHUB_PUSH_TOKEN }}
gh-pat: ${{ secrets.PAT_GITHUB }}
with:
username: ${{ vars.DOCKERHUB_PUSH_USERNAME }}
registry: docker.io
image-name: ${{ vars.DOCKERHUB_IMAGE_NAME }}
push: false

build:
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit ed5af8a

Please sign in to comment.