Skip to content

Commit

Permalink
Support to deploy specific image
Browse files Browse the repository at this point in the history
Before:

when tagged, it deploy all images

After:

Allow to deploy specific image with tag

* tag v1.17.0-1.n => deploy all images
* tag v1.17.0-debian-graylog-1.n => deploy graylog images

Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
  • Loading branch information
kenhys committed Jul 11, 2024
1 parent d52a22b commit 1654f63
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ jobs:
- name: Setup tags
run: |
set -x
BUILD_AMD64_IMAGE=0
tag=${{ github.ref_name }}
# e.g v1.17.0-debian-azureblob-amd64-1.1 => v1.17.0
vversion=${tag%%-*}
# e.g v1.17.0-debian-azureblob-amd64-1.1 => 1.1
release=${tag##*-}
case $tag in
v*-debian-*)
;;
v*-*)
BUILD_AMD64_IMAGE=1
echo "BUILD_AMD64_IMAGE=1" >> ${GITHUB_ENV}
;;
esac
component=${{ matrix.component }}
echo "CONTEXT=docker-image/v1.17/${component}" >> ${GITHUB_ENV}
for target in $(make echo-all-images); do
Expand All @@ -64,10 +78,18 @@ jobs:
tag1=$(echo $tags | cut -d',' -f1)
tag2=$(echo $tags | cut -d',' -f2)
echo "AMD64TAGS=${{ env.REPOSITORY }}:${tag1},${{ env.REPOSITORY }}:${tag2}" >> ${GITHUB_ENV}
if [ "$tag1" = "${vversion}-${component}-amd64-${release}" ]; then
BUILD_AMD64_IMAGE=1
echo "BUILD_AMD64_IMAGE=1" >> ${GITHUB_ENV}
fi
;;
esac
done
if [ $BUILD_AMD64_IMAGE -ne 1 ]; then
echo "AMD64 $component $tag image will not be deployed"
fi
- name: Build and push for amd64
if: ${{ env.BUILD_AMD64_IMAGE }}
uses: docker/build-push-action@v6
with:
context: ${{ env.CONTEXT }}
Expand Down Expand Up @@ -99,6 +121,20 @@ jobs:
- name: Setup tags
run: |
set -x
BUILD_ARM64_IMAGE=0
tag=${{ github.ref_name }}
# e.g v1.17.0-debian-azureblob-arm64-1.1 => v1.17.0
vversion=${tag%%-*}
# e.g v1.17.0-debian-azureblob-arm64-1.1 => 1.1
release=${tag##*-}
case $tag in
v*-debian-*)
;;
v*-*)
BUILD_ARM64_IMAGE=1
echo "BUILD_ARM64_IMAGE=1" >> ${GITHUB_ENV}
;;
esac
component=${{ matrix.component }}
echo "CONTEXT=docker-image/v1.17/arm64/${component}" >> ${GITHUB_ENV}
for target in $(make echo-all-images); do
Expand All @@ -108,10 +144,18 @@ jobs:
tag1=$(echo $tags | cut -d',' -f1)
tag2=$(echo $tags | cut -d',' -f2)
echo "ARM64TAGS=${{ env.REPOSITORY }}:${tag1},${{ env.REPOSITORY }}:${tag2}" >> ${GITHUB_ENV}
if [ "$tag1" = "${vversion}-${component}-arm64-${release}" ]; then
BUILD_ARM64_IMAGE=1
echo "BUILD_ARM64_IMAGE=1" >> ${GITHUB_ENV}
fi
;;
esac
done
if [ $BUILD_ARM64_IMAGE -ne 1 ]; then
echo "ARM64 $component $tag image will not be deployed"
fi
- name: Build and push for arm64
if: ${{ env.BUILD_ARM64_IMAGE }}
uses: docker/build-push-action@v6
with:
context: ${{ env.CONTEXT }}
Expand Down

0 comments on commit 1654f63

Please sign in to comment.