Create all tags, not just vX.Y.Z

This commit is contained in:
Alexander A. Klimov 2023-01-17 17:43:09 +01:00
parent d1fdb43ee0
commit 2a225c54cf
4 changed files with 37 additions and 3 deletions

View File

@ -26,6 +26,7 @@ runs:
shell: bash shell: bash
run: | run: |
'${{ github.action_path }}/build.bash' . push "$(tr -d v <<<'${{ github.ref_name }}')" '${{ github.action_path }}/build.bash' . push "$(tr -d v <<<'${{ github.ref_name }}')"
'${{ github.action_path }}/mktags.bash' '${{ github.ref_name }}'
- if: github.event_name == 'push' - if: github.event_name == 'push'
shell: bash shell: bash

View File

@ -24,9 +24,9 @@ if ! docker buildx version; then
false false
fi fi
COMMON_ARGS=(-t "icinga/icinga2:$TAG" --build-context "icinga2-git=$(realpath "$I2SRC")/.git" "$(realpath "$(dirname "$0")")") OUR_DIR="$(realpath "$(dirname "$0")")"
COMMON_ARGS=(-t "icinga/icinga2:$TAG" --build-context "icinga2-git=$(realpath "$I2SRC")/.git" "$OUR_DIR")
BUILDX=(docker buildx build --platform "$(echo linux/{amd64,arm{/v7,64/v8}} |tr ' ' ,)") BUILDX=(docker buildx build --platform "$(cat "${OUR_DIR}/platforms.txt")")
case "$ACTION" in case "$ACTION" in
all) all)

32
mktags.bash Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
# Icinga 2 Docker image | (c) 2023 Icinga GmbH | GPLv2+
set -exo pipefail
if [[ "$1" =~ ^v((([0-9]+).([0-9]+)).[0-9]+)$ ]]; then
XYZ="${BASH_REMATCH[1]}"
XY="${BASH_REMATCH[2]}"
X="${BASH_REMATCH[3]}"
Y="${BASH_REMATCH[4]}"
BUILDX=(docker buildx build --platform "$(cat "$(realpath "$(dirname "$0")")/platforms.txt")" --push)
cd "$(mktemp -d)"
echo "FROM icinga/icinga2:$XYZ" >Dockerfile
"${BUILDX[@]}" -t "icinga/icinga2:$XY" .
NEXT="${X}.$(($Y+1))"
case "$(curl --head -sSLo /dev/null -w '%{http_code}' "https://hub.docker.com/v2/namespaces/icinga/repositories/icinga2/tags/$NEXT")" in
200)
;;
404)
"${BUILDX[@]}" -t "icinga/icinga2:$X" .
"${BUILDX[@]}" -t icinga/icinga2 .
;;
*)
echo "Can't check for icinga/icinga2:$NEXT"
false
;;
esac
fi

1
platforms.txt Normal file
View File

@ -0,0 +1 @@
linux/amd64,linux/arm/v7,linux/arm64/v8