From 52da506215d0c78523edd30b22d29b7755228342 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 2 Jul 2024 17:28:02 +0100 Subject: [PATCH] ci: tag and push to envbox-preview on merge to main Signed-off-by: Cian Johnston --- .github/workflows/ci.yaml | 11 ++++++----- scripts/version.sh | 10 ++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100755 scripts/version.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e49595e..94a5eba 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -259,8 +259,9 @@ jobs: - name: build image run: make -j build/image/envbox - - name: tag image - run: docker tag envbox ghcr.io/coder/envbox:latest - - - name: push image - run: docker push ghcr.io/coder/envbox:latest + - name: Tag and push envbox-preview + run: | + VERSION=$(./scripts/version.sh)-dev-$(git rev-parse --short HEAD) + BASE=ghcr.io/coder/envbox-preview + docker tag envbox "${BASE}:${VERSION}" + docker push "${BASE}:${VERSION}" diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..31968d2 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" + +last_tag="$(git describe --tags --abbrev=0)" +version="$last_tag" + +# Remove the "v" prefix. +echo "${version#v}"