From c3c1f2e3e78b9071e8439ae7ade0849dfbb13b32 Mon Sep 17 00:00:00 2001 From: Choco Date: Mon, 16 Jun 2025 10:08:49 +0800 Subject: [PATCH] Update docker-image.yml --- .github/workflows/docker-image.yml | 42 +++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 53b4f72..9e05fa9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,9 +2,13 @@ name: Docker Image CI on: push: - branches: [ "main" ] + tags: + - '*' # Trigger on any tag + branches: + - main # Trigger on push to main branch + - beta # Trigger on push to beta branch paths-ignore: - - '**.md' + - '**.md' permissions: packages: write @@ -14,16 +18,28 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag vocard:latest + - uses: actions/checkout@v4 - - name: Log in to GitHub Docker Registry - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Build the Docker image + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + TAG=${GITHUB_REF#refs/tags/} + IMAGE_NAME="ghcr.io/chocomeow/vocard:${TAG}" + elif [[ $GITHUB_REF == refs/heads/beta ]]; then + IMAGE_NAME="ghcr.io/chocomeow/vocard:beta" + else + IMAGE_NAME="ghcr.io/chocomeow/vocard:latest" + fi + + echo "Building image: $IMAGE_NAME" + docker build . --file Dockerfile --tag $IMAGE_NAME + + - name: Log in to GitHub Docker Registry + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Push the Docker image - run: | - docker tag vocard:latest ghcr.io/chocomeow/vocard:latest # Ensure lowercase - docker push ghcr.io/chocomeow/vocard:latest # Ensure lowercase \ No newline at end of file + - name: Push the Docker image + run: | + echo "Pushing image: $IMAGE_NAME" + docker push $IMAGE_NAME \ No newline at end of file