Skip to content

GHA: update tags

GHA: update tags #345

name: Image releases
on:
push:
branches:
- main
tags:
- v*
# The idea here is we to reuse the images that we build during the PR phase. Since our builds are
# not reproducabe, this allow us to perform tests in the PR and ensure that everything works as
# expected when we do a release.
jobs:
tag-images:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Getting image tag
id: tag
run: |
echo tag=${GITHUB_REF##*/} | tee -a $GITHUB_OUTPUT
- name: setup docker buildx
uses: docker/setup-buildx-action@aa33708b10e362ff993539393ff100fa93ed6a27 # v3.5.0
- name: install crane
env:
VERSION: v0.19.1
run: |
URL="https://github.com/google/go-containerregistry/releases/download/${VERSION}/go-containerregistry_Linux_x86_64.tar.gz"
curl -fSL $URL | sudo tar -xz -C /usr/local/bin crane
- name: quay login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: tag images
run: |
name=${{ steps.tag.outputs.tag }}
echo $name
for f in $(find ./versions -type f ! -name README.md -printf "%P\n")
do
tag=$(cat ./versions/$f)
path_arch=$(echo $f | grep -oE 'arm64|amd64' || true)
arch_suffix=$( [ -n "$path_arch" ] && echo "-$path_arch" || true)
echo f=$f tag=$tag arch_suffix=$arch_suffix
src_image="quay.io/lvh-images/$(echo $f/$tag | sed -e 's_/arm64__;s_/amd64__' | sed -e 's_/_-ci:_; s_/_-_g')"
dst_image=$(echo $src_image | sed -e "s/$tag/$name/")
dst_image=$(echo $dst_image | sed -e 's/-ci:/:/')
dst_image=$(echo ${dst_image}${arch_suffix})
echo -e "\033[0;32m${src_image} -> ${dst_image}\e[0m";
crane copy $src_image $dst_image
# Only tag the "prod" image on pushes to main
if [[ "$name" == "main" ]]; then
dst_prod_image=$(echo $src_image | sed -e 's/-ci:/:/')
echo -e "\033[0;32m${src_image} -> ${dst_prod_image}\e[0m";
crane copy $src_image $dst_prod_image
fi
done
- name: create multi-arch kind images
run: |
# if it exists in arm64, it exists in amd64. The opposite is false for rhel8.
for f in $(find ./versions/kind/arm64 -type f -printf "%P\n")
do
tag=$(cat ./versions/kind/arm64/$f)
multi_tag=$(echo $tag | sed 's/-\(arm64\|amd64\)$//')
kind_image_name="quay.io/lvh-images/kind"
multi_image="$kind_image_name:$f-$multi_tag"
amd64_image="$multi_image-amd64"
arm64_image="$multi_image-arm64"
docker buildx imagetools create -t $kind_image_name:$f-main -t $multi_image $amd64_image $arm64_image
done
- name: create multi-arch root-images images
run: |
tag=$(cat ./versions/root-images/arm64)
multi_tag=$(echo $tag | sed 's/-\(arm64\|amd64\)$//')
root_images_name="quay.io/lvh-images/root-images"
multi_image="$root_images_name:$multi_tag"
amd64_image="$multi_image-amd64"
arm64_image="$multi_image-arm64"
docker buildx imagetools create -t $root_images_name:main -t $multi_image $amd64_image $arm64_image