ci(docker): update workflow to build and push Docker images

This commit is contained in:
ShiYu
2025-05-24 10:39:16 +08:00
parent 056b685eaa
commit 85a1298ed0

View File

@@ -2,14 +2,13 @@ name: Build and Push Docker image
on:
push:
branches:
- '**'
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
if: startsWith(github.event.head_commit.message, 'pub(docker)')
permissions:
contents: read
packages: write
@@ -21,6 +20,16 @@ jobs:
- name: Lowercase repo name
run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
- name: Set up Docker tags
id: meta
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
echo "DOCKER_TAGS=ghcr.io/${REPO_LC}:${VERSION},ghcr.io/${REPO_LC}:latest" >> $GITHUB_ENV
else
echo "DOCKER_TAGS=ghcr.io/${REPO_LC}:dev" >> $GITHUB_ENV
fi
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
@@ -33,4 +42,4 @@ jobs:
with:
context: .
push: true
tags: ghcr.io/${{ env.REPO_LC }}:dev
tags: ${{ env.DOCKER_TAGS }}