diff --git a/.github/workflows/docker_release.yml b/.github/workflows/docker_release.yml index 2a068b1f6..d8b2313ce 100644 --- a/.github/workflows/docker_release.yml +++ b/.github/workflows/docker_release.yml @@ -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 @@ -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