Updated workflows.

This commit is contained in:
Mike Cao 2025-12-11 16:41:23 -08:00
parent 3eb2e890ef
commit 7729bbf4a7
3 changed files with 53 additions and 71 deletions

View file

@ -1,11 +1,18 @@
name: Create docker images
on: [create]
on:
create:
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (e.g., v2.10.0, 2.10.0, v2.10, v2)'
required: true
type: string
jobs:
build:
name: Build, push, and deploy
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
strategy:
@ -14,6 +21,8 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
- name: Set env
run: |
@ -22,15 +31,41 @@ jobs:
- name: Generate tags
id: generate_tags
run: |
echo "tag_patch=$(echo ${{ matrix.db-type }})-${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "tag_minor=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1,2)" >> $GITHUB_ENV
echo "tag_major=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1)" >> $GITHUB_ENV
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
TAG=${{ inputs.tag }}
else
TAG=${GITHUB_REF#refs/tags/}
fi
# Remove 'v' prefix if present
VERSION=${TAG#v}
# Split version into parts
IFS='.' read -ra PARTS <<< "$VERSION"
# Generate tags based on number of version parts
if [ ${#PARTS[@]} -eq 1 ]; then
# Only major version (e.g., v2 or 2)
echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}" >> $GITHUB_ENV
elif [ ${#PARTS[@]} -eq 2 ]; then
# Major.minor version (e.g., v2.10 or 2.10)
echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
echo "tag_minor=$(echo ${{ matrix.db-type }})-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}, ${{ matrix.db-type }}-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
else
# Full version (e.g., v2.10.0 or 2.10.0)
echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
echo "tag_minor=$(echo ${{ matrix.db-type }})-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
echo "tag_patch=$(echo ${{ matrix.db-type }})-${VERSION}" >> $GITHUB_ENV
echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}, ${{ matrix.db-type }}-${PARTS[0]}.${PARTS[1]}, ${{ matrix.db-type }}-${VERSION}" >> $GITHUB_ENV
fi
- uses: mr-smithers-excellent/docker-build-push@v6
name: Build & push Docker image to ghcr.io for ${{ matrix.db-type }}
with:
image: umami
tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}
tags: ${{ env.TAGS }}
buildArgs: DATABASE_TYPE=${{ matrix.db-type }}
registry: ghcr.io
multiPlatform: true
@ -42,8 +77,8 @@ jobs:
name: Build & push Docker image to docker.io for ${{ matrix.db-type }}
with:
image: umamisoftware/umami
tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}
tags: ${{ env.TAGS }}
buildArgs: DATABASE_TYPE=${{ matrix.db-type }}
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
password: ${{ secrets.DOCKER_PASSWORD }}