Skip to content

Modernize build workflow and build multi-arch images #122

Modernize build workflow and build multi-arch images

Modernize build workflow and build multi-arch images #122

Workflow file for this run

# Build and push Docker image to public GCR
name: Build
on:
push:
branches:
- main
tags:
- "*"
pull_request:
branches:
- main
jobs:
build-and-push:
name: BuildAndPush
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: eu.gcr.io/quortex-registry-public/kubestatic
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login if the event is a push or a tag to be able to push
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
if: ${{ github.event_name != 'pull_request' }}
with:
token_format: access_token
workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_POOL }}
service_account: ${{ vars.SERVICE_ACCOUNT }}
- name: Login to GCR
uses: docker/login-action@v3
if: ${{ github.event_name != 'pull_request' }}
with:
registry: eu.gcr.io
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Prepare cross-compilation Dockerfile
run: sed -e '1 s/\(^FROM\)/FROM --platform=${BUILDPLATFORM}/; t' -e ' 1,// s//FROM --platform=${BUILDPLATFORM}/' Dockerfile > Dockerfile.cross
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.cross
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}