From de66e2f2fe1e54e7d2ed2d230fbe8dd7423f5f7a Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Sat, 3 Feb 2024 20:38:04 +0200 Subject: [PATCH] Publish distribution images with digests Signed-off-by: Stefan Prodan --- .github/workflows/index-images.sh | 57 +++++++++++++++++++++++++++ .github/workflows/index-images.yaml | 61 +++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100755 .github/workflows/index-images.sh create mode 100644 .github/workflows/index-images.yaml diff --git a/.github/workflows/index-images.sh b/.github/workflows/index-images.sh new file mode 100755 index 0000000..31cf02a --- /dev/null +++ b/.github/workflows/index-images.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +set -eoux pipefail + +REGISTRY="${REGISTRY}" +VARIANT="${VARIANT}" +VERSION="${VERSION}" + +ROOT_DIR="$(git rev-parse --show-toplevel)" +WORK_DIR="${ROOT_DIR}/images" + +mkdir -p "${WORK_DIR}" + +cd "${WORK_DIR}" + +FLUX_IMAGES="${VERSION}-${VARIANT}.yaml" + +flux install --version ${VERSION} \ +--registry=${REGISTRY}/${VARIANT} \ +--components-extra=image-reflector-controller,image-automation-controller \ +--export | grep 'ghcr.io/' | awk '{print $2}' > "${FLUX_IMAGES}" + + +sc=$(awk 'NR==1{print $1}' "${FLUX_IMAGES}") +sc_digest=$(docker buildx imagetools inspect ${sc} --format '{{json .}}' | jq -r .manifest.digest) +kc=$(awk 'NR==2{print $1}' "${FLUX_IMAGES}") +kc_digest=$(docker buildx imagetools inspect ${kc} --format '{{json .}}' | jq -r .manifest.digest) +hc=$(awk 'NR==3{print $1}' "${FLUX_IMAGES}") +hc_digest=$(docker buildx imagetools inspect ${hc} --format '{{json .}}' | jq -r .manifest.digest) +nc=$(awk 'NR==4{print $1}' "${FLUX_IMAGES}") +nc_digest=$(docker buildx imagetools inspect ${nc} --format '{{json .}}' | jq -r .manifest.digest) +irc=$(awk 'NR==5{print $1}' "${FLUX_IMAGES}") +irc_digest=$(docker buildx imagetools inspect ${irc} --format '{{json .}}' | jq -r .manifest.digest) +iac=$(awk 'NR==6{print $1}' "${FLUX_IMAGES}") +iac_digest=$(docker buildx imagetools inspect ${iac} --format '{{json .}}' | jq -r .manifest.digest) + +cat >${FLUX_IMAGES} <> $GITHUB_ENV + + VARIANT="alpine" \ + REGISTRY="${REGISTRY}" \ + VERSION="${VERSION}" \ + ./workflows/index-images.sh + + VARIANT="distroless" \ + REGISTRY="${REGISTRY}" \ + VERSION="${VERSION}" \ + ./workflows/index-images.sh + - name: Create Pull Request + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: | + Update images for Flux ${{ steps.update.outputs.version }} + committer: GitHub + signoff: true + branch: update-images-${{ steps.update.outputs.version }} + title: Update images for Flux ${{ steps.update.outputs.version }} + body: | + Update images with digests for Flux ${{ steps.update.outputs.version }} + labels: | + area/images