From 4a8d249457d9fe04f04d2a436814dd2b85d042b8 Mon Sep 17 00:00:00 2001 From: Brian Torres-Gil Date: Tue, 3 Jan 2023 11:43:04 -0800 Subject: [PATCH] ci: Fix issue with docker tags on release --- .github/workflows/ci.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c23132e..3d170cc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,36 +109,34 @@ jobs: - name: Determine docker tags and labels id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # On a release, tag with 'latest' and semantic versions (eg v3.2.1, v3.2, and v3) tags: | - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} type=ref,event=branch + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} + type=semver,pattern=v{{version}},value=${{ needs.release.outputs.new_release_version }},enable=${{ github.ref == 'refs/heads/master' && needs.release.result == 'success' }} + type=semver,pattern=v{{major}}.{{minor}},value=${{ needs.release.outputs.new_release_version }},enable=${{ github.ref == 'refs/heads/master' && needs.release.result == 'success' }} + type=semver,pattern=v{{major}},value=${{ needs.release.outputs.new_release_version }},enable=${{ github.ref == 'refs/heads/master' && needs.release.result == 'success' }} + type=semver,pattern=v{{version}},value=${{ needs.release.outputs.new_release_version }},enable=${{ github.ref == 'refs/heads/master' && needs.release.result == 'success' }} - name: Set the version in app.conf if: needs.release.result == 'success' && needs.release.outputs.new_release_published == 'true' run: scripts/set-version.sh ${{ needs.release.outputs.new_release_version }} ${{ needs.release.outputs.new_release_channel }} - - name: Create docker version tag - id: versiontag - if: needs.release.result == 'success' && needs.release.outputs.new_release_published == 'true' - run: echo "versiontag=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.new_release_version }}" >> $GITHUB_OUTPUT - - name: Login to Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: . file: demo/Dockerfile push: true - tags: | - ${{ steps.meta.outputs.tags }} - ${{ steps.versiontag.outputs.versiontag }} + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}