From a589af3588c578b75e28cee6c8088c9cb8f2dcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Thu, 7 Dec 2023 15:42:35 +0100 Subject: [PATCH] [DEVOPS-1654] Tag Server images in master with git commit (#3516) * Add image name with SHA * Test * Remove testing * Change name * Change to short SHA * Test * Fix * Remove testing * Test * Remove testing --- .github/workflows/build.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5f1d1c57..953d9547b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -300,12 +300,19 @@ jobs: echo "PROJECT_NAME: $PROJECT_NAME" echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT - - name: Generate image full name - id: image-name + - name: Generate image name(s) + id: image-names env: IMAGE_TAG: ${{ steps.tag.outputs.image_tag }} PROJECT_NAME: ${{ steps.setup.outputs.project_name }} - run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT + SHA: ${{ github.sha }} + run: | + NAMES="${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" + if [[ "${IMAGE_TAG}" == "dev" ]]; then + SHORT_SHA=$(git rev-parse --short ${SHA}) + NAMES=$NAMES",${_AZ_REGISTRY}/${PROJECT_NAME}:dev-${SHORT_SHA}" + fi + echo "names=$NAMES" >> $GITHUB_OUTPUT - name: Get build artifact if: ${{ matrix.dotnet }} @@ -327,7 +334,7 @@ jobs: file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile platforms: linux/amd64 push: true - tags: ${{ steps.image-name.outputs.name }} + tags: ${{ steps.image-names.outputs.names }} secrets: | "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"