Jelajahi Sumber

Add manual run

yhirose 5 bulan lalu
induk
melakukan
54e75dc8ef
1 mengubah file dengan 23 tambahan dan 5 penghapusan
  1. 23 5
      .github/workflows/release-docker.yml

+ 23 - 5
.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 }}