Skip to content

Multi-platform build #47

Multi-platform build

Multi-platform build #47

Workflow file for this run

name: Build docker image
on:
push:
branches: [ master ]
tags:
- 'v*.*.*'
paths:
- 'src/**.c'
- 'Dockerfile'
pull_request:
branches: [ master ]
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Merge build image & test image
run: cat Dockerfile Dockerfile.test > Dockerfile.merged
- name: Test
id: docker_test_image
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile.merged
push: false
cache-from: type=gha,scope=main
cache-to: type=gha,mode=max,scope=main
build:
needs:
- test
name: Build image
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{raw}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
id: docker_build_image
uses: docker/build-push-action@v5
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha,scope=main
cache-to: type=gha,mode=max,scope=main