Skip to content

Commit 6d6b23f

Browse files
Enhance Docker image release workflow with manual trigger and improved tag retrieval
1 parent 5752535 commit 6d6b23f

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

.github/workflows/docker-image_release.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,37 @@ on:
66
- "v*.*.*"
77
schedule:
88
- cron: '0 4 * * 0' # This will run the workflow every Sunday at 4 am
9+
workflow_dispatch:
10+
911

1012
jobs:
1113
docker:
1214
runs-on: ubuntu-latest
1315
steps:
1416
- name: Checkout
1517
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
1620

1721
- name: Get the latest tag
18-
id: get_latest_tag
19-
run: |
20-
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "")
21-
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
22-
22+
uses: oprypin/find-latest-tag@v1
23+
with:
24+
repository: wemove/read2burn # The repository to scan.
25+
releases-only: false # We know that all relevant tags have a GitHub release for them.
26+
regex: '^.+\.\d+\.\d+$'
27+
sort-tags: false
28+
id: read2burn # The step ID to refer to later.
29+
2330
- name: Checkout the latest tag if exists
24-
run: git checkout ${{ env.latest_tag }}
31+
run: git checkout tags/${{ steps.read2burn.outputs.tag }}
2532

2633
- name: Get the commit ID
2734
id: get_commit
2835
run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_ENV
2936

3037
- name: Inject version and commit ID into index.ejs
3138
run: |
32-
VERSION=${{ env.latest_tag }}
39+
VERSION=${{ steps.read2burn.outputs.tag }}
3340
COMMIT=${{ env.commit }}
3441
echo "<!-- Version: $VERSION, Commit ID: $COMMIT -->" >> views/index.ejs
3542
@@ -41,9 +48,9 @@ jobs:
4148
images: |
4249
wemove/read2burn
4350
tags: |
44-
type=semver,pattern={{version}}
45-
type=semver,pattern={{major}}
46-
type=semver,pattern={{major}}.{{minor}}
51+
type=semver,pattern={{version}},value=${{ steps.read2burn.outputs.tag }}
52+
type=semver,pattern={{major}},value=${{ steps.read2burn.outputs.tag }}
53+
type=semver,pattern={{major}}.{{minor}},value=${{ steps.read2burn.outputs.tag }}
4754
4855
- name: Login to Docker Hub
4956
uses: docker/login-action@v3
@@ -59,5 +66,4 @@ jobs:
5966
push: ${{ github.event_name != 'pull_request' }}
6067
file: docker/Dockerfile
6168
tags: ${{ steps.meta.outputs.tags }}
62-
labels: ${{ steps.meta.outputs.labels }}
63-
69+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)