chore: update Docker workflow for tagging

- Remove unnecessary steps for version extraction
- Simplify tag assignment using environment variables

This update cleans up the Docker workflow by eliminating steps
that were not crucial for the tagging process. The tagging
is now done directly with the repository name, reducing redundancy
and improving clarity in the workflow configuration.
This commit is contained in:
songtianlun 2025-01-22 09:19:28 +08:00
parent a988c49ae0
commit 48f3da8913

View File

@ -14,22 +14,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get version
id: get_version
run: |
GIT_VERSION=$(git describe --dirty --always --long --abbrev=7 --tags)
VERSION="v${GIT_VERSION}"
IMAGE_PREFIX="${{ env.REGISTRY }}/${{ secrets.DOCKERHUB_USER }}/${{ env.IMAGE_NAME }}"
LATEST_TAG="${IMAGE_PREFIX}:latest"
VERSION_TAG="${IMAGE_PREFIX}:${VERSION}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "GIT_VERSION=${GIT_VERSION}" >> $GITHUB_ENV
echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_OUTPUT
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_OUTPUT
- -
name: Login to ${{ env.REGISTRY }} name: Login to ${{ env.REGISTRY }}
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
@ -50,6 +34,4 @@ jobs:
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: | tags: ${{ env.REGISTRY }}/${{ secrets.DOCKER_HUB_USER }}/${{ github.event.repository.name }}:latest
${{ env.LATEST_TAG }}
${{ env.VERSION_TAG }}