chore: update docker workflow to be default branch aware

This commit is contained in:
William Oldham 2025-05-20 22:58:17 +01:00
parent cad56cd5b8
commit 462afd7c04

View File

@ -8,12 +8,12 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DEFAULT_BRANCH: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }}
SHOULD_PUSH_IMAGE: ${{ (github.event_name == 'push' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.ref == 'refs/heads/dev')) || github.event_name == 'workflow_dispatch' }}
jobs:
build-publish-amd64:
name: Build and Publish Docker Image (amd64)
env:
SHOULD_PUSH_IMAGE: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
permissions:
@ -41,7 +41,7 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
type=raw,value=latest,enable=${{ github.ref == env.DEFAULT_BRANCH }}
type=raw,value=edge,enable=${{ github.ref == 'refs/heads/dev' }}
type=sha
@ -58,8 +58,6 @@ jobs:
build-publish-arm64:
name: Build and Publish Docker Image (arm64)
env:
SHOULD_PUSH_IMAGE: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-24.04-arm
permissions:
@ -87,7 +85,7 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest-arm,enable=${{ github.ref == 'refs/heads/master' }}
type=raw,value=latest-arm,enable=${{ github.ref == env.DEFAULT_BRANCH }}
type=raw,value=edge-arm,enable=${{ github.ref == 'refs/heads/dev' }}
type=sha,suffix=-arm