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
This commit is contained in:
Debanjum Singh Solanky 2023-12-21 17:29:37 +05:30
parent b5ae64cb3c
commit 8d1e988059
2 changed files with 10 additions and 4 deletions

View file

@ -16,7 +16,8 @@ on:
workflow_dispatch: workflow_dispatch:
env: 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: jobs:
build: build:
@ -47,7 +48,9 @@ jobs:
file: Dockerfile file: Dockerfile
platforms: linux/amd64, linux/arm64 platforms: linux/amd64, linux/arm64
push: true 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: | build-args: |
VERSION=${{ steps.hatch.outputs.version }} VERSION=${{ steps.hatch.outputs.version }}
PORT=42110 PORT=42110

View file

@ -20,7 +20,8 @@ on:
workflow_dispatch: workflow_dispatch:
env: 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: jobs:
build: build:
@ -51,7 +52,9 @@ jobs:
file: prod.Dockerfile file: prod.Dockerfile
platforms: linux/amd64 platforms: linux/amd64
push: true 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: | build-args: |
VERSION=${{ steps.hatch.outputs.version }} VERSION=${{ steps.hatch.outputs.version }}
PORT=42110 PORT=42110