From 8d1e9880592095464a538b18e6a142526ddd54f5 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 21 Dec 2023 17:29:37 +0530 Subject: [PATCH] Update tagging of the docker image on release, push to master & PR - Tag docker image with `tag_name' on release (i.e tag push) - Else tag with 'pre' on push to master - Else tag with 'dev' on push to PR branch - Only tag the latest release with release tag Previously the latest commit on master was being tagged with the latest tag. This doesn't sync with the release cadence of the rest of Khoj --- .github/workflows/dockerize.yml | 7 +++++-- .github/workflows/dockerize_production.yml | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerize.yml b/.github/workflows/dockerize.yml index e0e63ccd..bc2da688 100644 --- a/.github/workflows/dockerize.yml +++ b/.github/workflows/dockerize.yml @@ -16,7 +16,8 @@ on: workflow_dispatch: env: - DOCKER_IMAGE_TAG: ${{ github.ref == 'refs/heads/master' && 'latest' || github.ref_name }} + # Tag Image with tag name on release, else with 'pre' if push to master + DOCKER_IMAGE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || 'pre' }} jobs: build: @@ -47,7 +48,9 @@ jobs: file: Dockerfile platforms: linux/amd64, linux/arm64 push: true - tags: ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }} + tags: | + ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }} + ${{ github.ref_type == 'tag' && 'ghcr.io/${{ github.repository }}-cloud:latest' || '' }} build-args: | VERSION=${{ steps.hatch.outputs.version }} PORT=42110 diff --git a/.github/workflows/dockerize_production.yml b/.github/workflows/dockerize_production.yml index a0b86981..a42aa8d9 100644 --- a/.github/workflows/dockerize_production.yml +++ b/.github/workflows/dockerize_production.yml @@ -20,7 +20,8 @@ on: workflow_dispatch: env: - DOCKER_IMAGE_TAG: ${{ github.event_name == 'pull_request' && 'dev' || (github.ref == 'refs/heads/master' && 'latest' || github.ref_name) }} + # Tag Image with tag name on release, else with 'pre' if push to master else with 'dev' if push to PR branch + DOCKER_IMAGE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || github.event_name == 'pull_request' && 'dev' || 'pre' }} jobs: build: @@ -51,7 +52,9 @@ jobs: file: prod.Dockerfile platforms: linux/amd64 push: true - tags: ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }} + tags: | + ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }} + ${{ github.ref_type == 'tag' && 'ghcr.io/${{ github.repository }}-cloud:latest' || '' }} build-args: | VERSION=${{ steps.hatch.outputs.version }} PORT=42110