Skip to content

Commit 54e75dc

Browse files
committed
Add manual run
1 parent b20b5fd commit 54e75dc

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1+
2+
3+
14
name: Release Docker Image
25

36
on:
47
release:
58
types: [published]
9+
workflow_dispatch:
610

711
jobs:
812
build-and-push:
913
runs-on: ubuntu-latest
1014
steps:
1115
- name: Checkout code
1216
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # Fetch all history and tags
19+
20+
- name: Extract tag (manual)
21+
if: github.event_name == 'workflow_dispatch'
22+
id: set_tag_manual
23+
run: |
24+
# Checkout the latest tag and set output
25+
git fetch --tags
26+
LATEST_TAG=$(git describe --tags --abbrev=0)
27+
git checkout $LATEST_TAG
28+
echo "tag=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
29+
30+
- name: Extract tag (release)
31+
if: github.event_name == 'release'
32+
id: set_tag_release
33+
run: echo "tag=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
1334

1435
- name: Set up Docker Buildx
1536
uses: docker/setup-buildx-action@v3
@@ -20,16 +41,13 @@ jobs:
2041
username: ${{ secrets.DOCKERHUB_USERNAME }}
2142
password: ${{ secrets.DOCKERHUB_TOKEN }}
2243

23-
- name: Extract version tag without 'v'
24-
id: set_tag
25-
run: echo "tag=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
26-
2744
- name: Build and push Docker image
2845
uses: docker/build-push-action@v5
2946
with:
3047
context: .
3148
file: ./Dockerfile
3249
push: true
50+
# Use extracted tag without leading 'v'
3351
tags: |
3452
yhirose4dockerhub/cpp-httplib-server:latest
35-
yhirose4dockerhub/cpp-httplib-server:${{ steps.set_tag.outputs.tag }}
53+
yhirose4dockerhub/cpp-httplib-server:${{ steps.set_tag_manual.outputs.tag || steps.set_tag_release.outputs.tag }}

0 commit comments

Comments
 (0)