Skip to content

Commit 03fbd92

Browse files
authored
Merge pull request #1566 from dwertent/fix-1506
Tag image as latest only when releasing the latest tag
2 parents 74e2cbd + 802dd18 commit 03fbd92

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

.github/workflows/docker_release.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,28 @@ on:
55
types: [released, prereleased]
66

77
jobs:
8+
fetch-latest-tag:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
latest_tag: ${{ steps.get_latest_tag.outputs.latest_tag }}
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Fetch all tags
19+
run: git fetch --tags
20+
21+
- name: Get the latest tag
22+
id: get_latest_tag
23+
run: |
24+
latest_tag=$(git tag -l | sort -V | tail -n 1)
25+
echo "::set-output name=latest_tag::${latest_tag}"
26+
827
docker:
928
runs-on: ubuntu-latest
29+
needs: fetch-latest-tag
1030
permissions:
1131
contents: read
1232
packages: write
@@ -30,7 +50,7 @@ jobs:
3050
password: ${{ secrets.GITHUB_TOKEN }}
3151

3252
- name: Set latest tag
33-
if: github.event.action == 'released'
53+
if: github.event.action == 'released' && github.ref_name == needs.fetch-latest-tag.outputs.latest_tag
3454
run: |
3555
echo "DOCKER_TAGS=${{ env.DOCKER_TAGS }},ghcr.io/${{ github.repository }}:latest" >> $GITHUB_ENV
3656

0 commit comments

Comments
 (0)