Skip to content

enable multiplatform builds #798

enable multiplatform builds

enable multiplatform builds #798

Workflow file for this run

name: Build & Test & Push Image
on:
push:
branches:
- "main"
- "develop"
tags:
- "v*"
pull_request:
branches:
- "main"
- "develop"
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
name: "Test and Build"
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn
cache-dependency-path: "ui/yarn.lock"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/f-eld-ch/sitrep
tags: |
# set latest tag for default branch / ordered by priority
type=semver,pattern={{version}},prefix=v,priority=920
type=raw,value=stable,enable=${{ github.ref == format('refs/heads/{0}', 'main') }},priority=910
type=raw,value=develop,enable={{is_default_branch}},priority=905
# priority 900
type=semver,pattern={{major}}.{{minor}},prefix=v
type=semver,pattern={{major}},prefix=v
# priority 700
type=edge,branch=develop
# priority 600
type=ref,event=branch
type=ref,event=pr,prefix=pr-,enable=true
- name: Install packages
run: yarn install --immutable
working-directory: ui
- name: Run ui tests
run: yarn test
working-directory: ui
- name: Build ui
run: yarn build
env:
VERSION: ${{ steps.meta.outputs.version }}
GIT_SHA: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
working-directory: ui
- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
GIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
- name: Docker meta for hasura
id: meta-hasura
uses: docker/metadata-action@v5
with:
images: ghcr.io/f-eld-ch/sitrep-hasura
tags: |
# set latest tag for default branch
type=edge,branch=develop
type=raw,value=stable,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=ref,event=branch
type=ref,event=pr,prefix=pr-,enable=true,priority=600
type=semver,pattern={{version}},prefix=v,priority=420
type=semver,pattern={{major}}.{{minor}},prefix=v,priority=410
type=semver,pattern={{major}},prefix=v,priority=400
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.hasura
platforms: ${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-hasura.outputs.tags }}
labels: ${{ steps.meta-hasura.outputs.labels }}