From 54e75dc8ef4dd92cda46c5d83222ea01bfabf8a2 Mon Sep 17 00:00:00 2001 From: yhirose Date: Tue, 26 Aug 2025 23:34:18 -0400 Subject: [PATCH] Add manual run --- .github/workflows/release-docker.yml | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 1038bf8..80a5c07 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -1,8 +1,12 @@ + + + name: Release Docker Image on: release: types: [published] + workflow_dispatch: jobs: build-and-push: @@ -10,6 +14,23 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history and tags + + - name: Extract tag (manual) + if: github.event_name == 'workflow_dispatch' + id: set_tag_manual + run: | + # Checkout the latest tag and set output + git fetch --tags + LATEST_TAG=$(git describe --tags --abbrev=0) + git checkout $LATEST_TAG + echo "tag=${LATEST_TAG#v}" >> $GITHUB_OUTPUT + + - name: Extract tag (release) + if: github.event_name == 'release' + id: set_tag_release + run: echo "tag=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -20,16 +41,13 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Extract version tag without 'v' - id: set_tag - run: echo "tag=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT - - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile push: true + # Use extracted tag without leading 'v' tags: | yhirose4dockerhub/cpp-httplib-server:latest - yhirose4dockerhub/cpp-httplib-server:${{ steps.set_tag.outputs.tag }} + yhirose4dockerhub/cpp-httplib-server:${{ steps.set_tag_manual.outputs.tag || steps.set_tag_release.outputs.tag }}