Skip to content

Adjusted a bit how tests are configured #65

Adjusted a bit how tests are configured

Adjusted a bit how tests are configured #65

Workflow file for this run

---
name: Build docker image
on:
push:
tags:
- "v*"
branches:
- "main"
- "develop"
- "feature/*"
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
strategy:
matrix:
include:
- platform: linux/amd64
platform_suffix: amd64
runner: ubuntu-24.04
- platform: linux/arm64
platform_suffix: arm64
runner: ubuntu-24.04
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version
id: extract-version
run: |
echo "VERSION=edge" >> "$GITHUB_OUTPUT"
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
fi
- name: Generate docker tags/labels from github build context
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Having version in suffix (either edge or <tag>) prevents collision for tag images which have a different version
tags: |
type=sha,prefix=,suffix=-${{ steps.extract-version.outputs.VERSION }}-${{ matrix.platform_suffix }}
flavor: |
suffix=-${{ matrix.platform_suffix }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.extract-version.outputs.VERSION }}
provenance: false
push:
needs: build
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate docker tags/labels from github build context
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=sha,prefix=
type=raw,enable=${{ github.ref == 'refs/heads/main' }},value=main
type=raw,enable=${{ github.ref == 'refs/heads/develop' }},value=develop
type=raw,enable=${{ startsWith(github.ref, 'refs/heads/feature/') }},value={{branch}}
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'rc') }}
sep-tags: ","
- name: Extract image
id: image
run: |
version="edge"
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
version=${GITHUB_REF#refs/tags/}
fi
echo "ID=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_SHA::7}-${version}" >> "$GITHUB_OUTPUT"
- name: Create and push manifest images
uses: Noelware/docker-manifest-action@v1
with:
inputs: "${{ steps.image.outputs.ID }}-amd64, ${{ steps.image.outputs.ID }}-arm64"
tags: "${{ steps.meta.outputs.tags }}"
push: true
slack-notifications:
needs: [build, push]
runs-on: ubuntu-24.04
if: always()
steps:
- name: Slack notification
if: needs.push.result == 'success'
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/action-slack@2.0.2
with:
args: |
:done: *${{ github.repository }}* Success building docker images from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: