From 55703521e9e921b74868d55cd14386e37a0b4b67 Mon Sep 17 00:00:00 2001 From: Trance233 <57557139+popjdh@users.noreply.github.com> Date: Sun, 31 Mar 2024 16:25:32 +0800 Subject: [PATCH] Server Docker Image Github CI Fix (#333) ci: fix job name error ci: add tag option for manual deployment --- .github/workflows/docker-server.yml | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-server.yml b/.github/workflows/docker-server.yml index 3fb44531..a60036a9 100644 --- a/.github/workflows/docker-server.yml +++ b/.github/workflows/docker-server.yml @@ -1,16 +1,20 @@ name: Docker - Server on: - push: - tags: - - "v*" + release: + types: [created] workflow_dispatch: + inputs: + tag: + description: 'Tag to use (leave empty for latest)' + required: false + default: '' env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }}-server jobs: - nightly: + build: runs-on: ubuntu-22.04 permissions: contents: read @@ -18,6 +22,21 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Grub Tag + run: | + if [[ "${{ github.event_name }}" == "release" ]]; then + echo "Using release tag ${{ github.event.release.tag_name }}" + echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV + elif [[ -z "${{ github.event.inputs.tag }}" ]]; then + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "Using latest tag $LATEST_TAG" + echo "TAG=$LATEST_TAG" >> $GITHUB_ENV + else + echo "Using manually specified tag ${{ github.event.inputs.tag }}" + echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV + fi - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' uses: docker/login-action@v2 @@ -29,8 +48,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - tags: | - type=semver,pattern={{version}} + tags: type=raw,value=${{ env.TAG }} images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image uses: docker/build-push-action@v3