Skip to content

Commit 6970164

Browse files
[MISC] Fixed build workflow involving multiple tags (#1371)
* [MISC] Fixed build workflow involving multiple tags * [MISC] Added option to build workflow to accept latest tag * [MISC] Avoid push of image to test build workflow changes * [MISC] Uncommented push option of bake that was added for testing
1 parent 3936218 commit 6970164

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

.github/workflows/production-build.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
tag:
77
description: "Docker image tag"
88
required: true
9+
set_as_latest:
10+
description: "Set as latest release"
11+
type: boolean
12+
default: false
13+
required: false
914

1015
release:
1116
types:
@@ -57,13 +62,14 @@ jobs:
5762
echo "Service ${{ matrix.service_name }} not found in docker-compose.build.yaml" && exit 1
5863
fi
5964
60-
# Set latest tag for releases
61-
if [ "${{ github.event_name }}" = "release" ]; then
62-
echo "latest=true" >> $GITHUB_OUTPUT
63-
echo "IMAGE_TAGS=unstract/${{ matrix.service_name }}:${{ env.DOCKER_VERSION_TAG }},unstract/${{ matrix.service_name }}:latest" >> $GITHUB_ENV
65+
# Set latest tag for releases or when explicitly requested
66+
echo "SEMVER_IMAGE_TAG=unstract/${{ matrix.service_name }}:${{ env.DOCKER_VERSION_TAG }}" >> $GITHUB_ENV
67+
68+
# Set latest tag if it's a release or if set_as_latest is true
69+
if [ "${{ github.event_name }}" = "release" ] || [ "${{ github.event.inputs.set_as_latest }}" = "true" ]; then
70+
echo "LATEST_IMAGE_TAG=unstract/${{ matrix.service_name }}:latest" >> $GITHUB_ENV
6471
else
65-
echo "latest=false" >> $GITHUB_OUTPUT
66-
echo "IMAGE_TAGS=unstract/${{ matrix.service_name }}:${{ env.DOCKER_VERSION_TAG }}" >> $GITHUB_ENV
72+
echo "LATEST_IMAGE_TAG=" >> $GITHUB_ENV
6773
fi
6874
6975
# Build and push using Docker Bake
@@ -75,9 +81,9 @@ jobs:
7581
files: ./docker/docker-compose.build.yaml
7682
targets: ${{ matrix.service_name }}
7783
push: true
78-
# Context resolved along with docker-compose.build.yaml, ensure resolved path is repo root
7984
set: |
80-
*.tags=${{ env.IMAGE_TAGS }}
85+
*.tags=${{ env.SEMVER_IMAGE_TAG }}
86+
${{ env.LATEST_IMAGE_TAG && format('*.tags={0}', env.LATEST_IMAGE_TAG) || '' }}
8187
*.context=.
8288
*.args.VERSION=${{ env.DOCKER_VERSION_TAG }}
8389
*.cache-from=type=gha,scope=${{ matrix.service_name }}

0 commit comments

Comments
 (0)