Skip to content

Commit

Permalink
Merge pull request #1566 from dwertent/fix-1506
Browse files Browse the repository at this point in the history
Tag image as latest only when releasing the latest tag
  • Loading branch information
EnriqueL8 authored Sep 6, 2024
2 parents 74e2cbd + 802dd18 commit 03fbd92
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,28 @@ on:
types: [released, prereleased]

jobs:
fetch-latest-tag:
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.get_latest_tag.outputs.latest_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --tags

- name: Get the latest tag
id: get_latest_tag
run: |
latest_tag=$(git tag -l | sort -V | tail -n 1)
echo "::set-output name=latest_tag::${latest_tag}"
docker:
runs-on: ubuntu-latest
needs: fetch-latest-tag
permissions:
contents: read
packages: write
Expand All @@ -30,7 +50,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

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

0 comments on commit 03fbd92

Please sign in to comment.