From 701ea6f7f8107569bab6809d99d80bc693b07bc2 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Fri, 7 Jun 2024 11:59:33 +0100 Subject: [PATCH] add latest tags to versioned infra and webapp builds --- .github/workflows/publish-docker.yml | 17 +++++++++++++++-- .github/workflows/publish-infra.yml | 9 +++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index e8d943724..ef98fc339 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -39,11 +39,25 @@ jobs: exit 1 fi echo "::set-output name=version::${IMAGE_TAG}" + - name: 🔢 Get the commit hash id: get_commit run: | echo ::set-output name=sha_short::$(echo ${{ github.sha }} | cut -c1-7) + - name: 📛 Set the tags + id: set_tags + run: | + ref_without_tag=ghcr.io/triggerdotdev/trigger.dev + image_tags=$ref_without_tag:${{ steps.get_version.outputs.version }} + + # if it's a versioned tag, also tag it as latest + if [[ "${{ github.ref_name }}" == v.docker.* ]]; then + image_tags=$image_tags,$ref_without_tag:latest + fi + + echo "IMAGE_TAGS=${image_tags}" >> "$GITHUB_OUTPUT" + - name: 🐙 Login to GitHub Container Registry uses: docker/login-action@v2 with: @@ -56,6 +70,5 @@ jobs: with: file: ./docker/Dockerfile platforms: linux/amd64,linux/arm64 - tags: | - ghcr.io/triggerdotdev/trigger.dev:${{ steps.get_version.outputs.version }} + tags: ${{ steps.set_tags.outputs.IMAGE_TAGS }} push: true diff --git a/.github/workflows/publish-infra.yml b/.github/workflows/publish-infra.yml index f10416991..92be7dcf7 100644 --- a/.github/workflows/publish-infra.yml +++ b/.github/workflows/publish-infra.yml @@ -110,3 +110,12 @@ jobs: REGISTRY: ghcr.io/triggerdotdev REPOSITORY: ${{ steps.prep.outputs.REPOSITORY }} IMAGE_TAG: ${{ steps.prep.outputs.IMAGE_TAG }} + + - name: 🐙 Push 'latest' to GitHub Container Registry + if: startsWith(github.ref_name, 'v.docker.') + run: | + docker tag infra_image $REGISTRY/$REPOSITORY:latest + docker push $REGISTRY/$REPOSITORY:latest + env: + REGISTRY: ghcr.io/triggerdotdev + REPOSITORY: ${{ steps.prep.outputs.REPOSITORY }}