Refactor Docker workflow to include version and production inputs, and streamline tag determination.
72 lines
2.2 KiB
YAML
72 lines
2.2 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Version to build, e.g. 1.8.0"
|
|
required: true
|
|
production:
|
|
description: "Set true for prod build, false for dev build"
|
|
required: true
|
|
default: false
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: arm64,arm/v7,arm/v6
|
|
|
|
- uses: useblacksmith/setup-docker-builder@v1
|
|
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: lukegus
|
|
password: ${{ secrets.GHCR_TOKEN }}
|
|
|
|
- uses: docker/login-action@v3
|
|
if: ${{ github.event.inputs.production == 'true' }}
|
|
with:
|
|
username: bugattiguy527
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Determine Docker tags
|
|
id: tags
|
|
run: |
|
|
VERSION="${{ github.event.inputs.version }}"
|
|
PRODUCTION="${{ github.event.inputs.production }}"
|
|
if [ "$PRODUCTION" == "true" ]; then
|
|
TAGS="ghcr.io/lukegus/termix:release-$VERSION ghcr.io/lukegus/termix:latest docker.io/bugattiguy527/termix:release-$VERSION docker.io/bugattiguy527/termix:latest"
|
|
else
|
|
TAGS="ghcr.io/lukegus/termix:dev-$VERSION"
|
|
fi
|
|
echo "TAGS=$TAGS" >> $GITHUB_ENV
|
|
echo "Docker tags: $TAGS"
|
|
|
|
- uses: useblacksmith/build-push-action@v2
|
|
with:
|
|
context: .
|
|
file: ./docker/Dockerfile
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
|
|
tags: ${{ env.TAGS }}
|
|
labels: |
|
|
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
build-args: |
|
|
BUILDKIT_INLINE_CACHE=1
|
|
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
|
|
outputs: type=registry,compression=zstd,compression-level=19
|
|
|
|
- run: |
|
|
docker image prune -af
|
|
docker system prune -af --volumes
|
|
if: always()
|