Skip to content

Commit dd5271a

Browse files
committed
ci(publish): enables workflow_dispatch event trigger
Signed-off-by: Dwi Siswanto <[email protected]>
1 parent 335ce85 commit dd5271a

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

.github/workflows/publish.yaml

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
11
name: Publish
22
on:
3-
create:
3+
push:
44
tags:
5-
- v*
5+
- 'v*'
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Git tag to release'
10+
required: true
11+
type: string
612

713
jobs:
814
publish:
915
name: "Publish to DockerHub"
1016
runs-on: ubuntu-latest
17+
env:
18+
VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
1119
steps:
12-
- name: "Check out code"
13-
uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
ref: "${{ env.VERSION }}"
1424

15-
- name: "Set up QEMU"
16-
uses: docker/[email protected]
17-
18-
- name: "Set up Docker Buildx"
19-
uses: docker/[email protected]
20-
21-
- name: "Login to DockerHub"
22-
uses: docker/[email protected]
25+
- uses: docker/metadata-action@v5
26+
id: meta
2327
with:
24-
username: ${{ secrets.DOCKER_USERNAME }}
25-
password: ${{ secrets.DOCKER_TOKEN }}
26-
27-
- name: "Build and push"
28-
id: docker_build
29-
uses: docker/[email protected]
28+
images: ${{ github.repository }}
29+
tags: |
30+
type=schedule
31+
type=semver,pattern={{version}},value=${{ env.VERSION }},match=v(\d.\d.\d)
32+
type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }},match=v(\d.\d)
33+
type=semver,pattern={{major}},value=${{ env.VERSION }},match=v(\d)
34+
type=sha
35+
36+
- uses: docker/setup-qemu-action@v3
37+
- uses: docker/setup-buildx-action@v3
38+
- uses: docker/login-action@v3
39+
with:
40+
username: "${{ secrets.DOCKER_USERNAME }}"
41+
password: "${{ secrets.DOCKER_TOKEN }}"
42+
43+
- uses: docker/build-push-action@v6
3044
with:
3145
push: true
32-
build-args: "VERSION=${{ github.ref_name }}"
33-
tags: "${{ github.repository }}:latest,${{ github.repository }}:${{ github.ref_name }}"
34-
35-
- name: "Image digest"
36-
run: echo ${{ steps.docker_build.outputs.digest }}
46+
build-args: |
47+
VERSION=${{ env.VERSION }}
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)