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
+14 -5
View File
@@ -2,14 +2,13 @@ name: Build and Push Docker image
on: on:
push: push:
branches: tags:
- '**' - 'v*.*.*'
workflow_dispatch:
jobs: jobs:
build-and-push: build-and-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: startsWith(github.event.head_commit.message, 'pub(docker)')
permissions: permissions:
contents: read contents: read
packages: write packages: write
@@ -21,6 +20,16 @@ jobs:
- name: Lowercase repo name - name: Lowercase repo name
run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV 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 - name: Log in to GitHub Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
@@ -33,4 +42,4 @@ jobs:
with: with:
context: . context: .
push: true push: true
tags: ghcr.io/${{ env.REPO_LC }}:dev tags: ${{ env.DOCKER_TAGS }}