Rework Docker workflow to push both alpine and ubuntu variants

This commit is contained in:
Luke Street 2025-10-07 15:28:24 -06:00
parent 928499a2db
commit de63a0b394

View File

@ -3,41 +3,60 @@ on:
push: push:
branches: [ main ] branches: [ main ]
tags: [ '*.*.*' ] tags: [ '*.*.*' ]
pull_request:
jobs: jobs:
public_docker_image: publish_docker_image:
name: Publish Docker image to Github Registry name: Publish Docker image to Github Registry (${{ matrix.display }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
packages: write packages: write
strategy:
fail-fast: false
matrix:
include:
- id: alpine
display: Alpine
dockerfile: Dockerfile
default: true
- id: ubuntu
display: Ubuntu
dockerfile: Dockerfile.ubuntu
default: false
steps: steps:
- name: Docker meta - name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
with: with:
images: ghcr.io/decompals/wibo images: ghcr.io/decompals/wibo
tags: |
type=raw,value=latest,enable=${{ matrix.default && github.ref_type == 'tag' }}
type=raw,value=latest-${{ matrix.id }},enable=${{ github.ref_type == 'tag' }}
type=ref,event=tag,enable=${{ matrix.default }}
type=ref,event=tag,suffix=-${{ matrix.id }}
type=ref,event=branch,enable=${{ matrix.default }}
type=ref,event=branch,suffix=-${{ matrix.id }}
type=sha,enable=${{ matrix.default }}
type=sha,suffix=-${{ matrix.id }}
flavor: |
latest=false
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Log in to GitHub Docker Registry - name: Log in to GitHub Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to Github registry (latest) - name: Build and push to Github registry
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
push: true file: ${{ matrix.dockerfile }}
tags: ghcr.io/decompals/wibo:latest push: ${{ github.event_name != 'pull_request' }}
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
- name: Build and push to Github registry (versioned)
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
if: startsWith(github.ref, 'refs/tags/') labels: ${{ steps.meta.outputs.labels }}