Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): fix main build pipeline #351

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 15 additions & 47 deletions .github/workflows/__build-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,51 +223,16 @@ jobs:
# Use outputs when push is set to false to allow subsequent steps to have
# access to this image.
# Ref: https://docs.docker.com/build/ci/github-actions/test-before-push/
outputs: ${{ !inputs.push && 'type=docker,dest=/tmp/image.tar' }}
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: Load the image into Docker
if: ${{ !inputs.push }}
run: docker load --input /tmp/image.tar

- 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 +241,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 +262,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
Loading