Update docker/build-push-action action to v6.19.2 #666
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Getting image tag | |
| id: tag | |
| run: | | |
| echo tag=${GITHUB_REF##*/} | tee -a $GITHUB_OUTPUT | |
| - name: setup docker buildx | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.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@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.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 is typically in the form of 20251028.102819, 20251028.102819-arm64 or 20251028.102819-sid-amd64 | |
| tag=$(cat ./versions/$f) | |
| path_arch=$(echo $f | grep -oE 'arm64|amd64' || true) | |
| arch_suffix=$( [ -n "$path_arch" ] && echo "-$path_arch" || true) | |
| path_pkg_repo=$(echo $f | grep -oE 'bookworm|sid' || true) | |
| pkg_repo_suffix=$( [ -n "$path_pkg_repo" ] && echo "-$path_pkg_repo" || true) | |
| echo f=$f tag=$tag arch_suffix=$arch_suffix pkg_repo_suffix=$pkg_repo_suffix | |
| # Build the full source image name (e.g. quay.io/lvh-images/kind-ci:6.12-20251028.102819-amd64) | |
| # This is where things get weird because some specifics are only stored | |
| # in the path hierarchy (kernel version) but others (arch and pkg_repo) | |
| # are duplicated in the path hierarchy and the tag. This is explained | |
| # by the fact that the kernel version is part of the image name while | |
| # arch and pkg_repo are part of the tag. | |
| src_image="quay.io/lvh-images/$(echo $f/$tag | sed -e 's_/arm64__;s_/amd64__' | sed -e 's_/bookworm__;s_/sid__' | sed -e 's_/_-ci:_; s_/_-_g')" | |
| # Build the full destination image name (e.g. quay.io/lvh-images/kind:main-amd64) | |
| dst_image=$(echo $src_image | sed -e "s/$tag/$name/") | |
| dst_image=$(echo $dst_image | sed -e 's/-ci:/:/') | |
| dst_image=$(echo ${dst_image}${pkg_repo_suffix}${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 | |
| # Just remove the -ci suffix from the image repo (e.g. quay.io/lvh-images/kind:20251028.102819-amd64) | |
| 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: tag amd64 mono-arch rhel8 images | |
| run: | | |
| # tag without the arch suffix for rhel8 since we only build for amd64 | |
| for f in $(find ./versions/kind/amd64/ -type f -name rhel8* -printf "%P\n") | |
| do | |
| tag=$(cat ./versions/kind/amd64/$f) | |
| kind_image_name="quay.io/lvh-images/kind" | |
| final_tag=$f-$(echo $tag | sed 's/-\(amd64\)$//') | |
| src_img=$kind_image_name:$f-$tag | |
| echo -e "tagging image \033[0;32m$src_img\e[0m with tag \033[0;32m$final_tag\e[0m" | |
| crane tag $src_img $final_tag | |
| main_src_img=$kind_image_name:$f-main-amd64 | |
| main_tag=$f-main | |
| echo -e "tagging image \033[0;32m$main_src_img\e[0m with tag \033[0;32m$main_tag\e[0m" | |
| crane tag $main_src_img $main_tag | |
| done | |
| - name: create multi-arch root-images images | |
| run: | | |
| for pkg_repo in bookworm sid; do | |
| tag=$(cat ./versions/root-images/$pkg_repo/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-$pkg_repo -t $multi_image $amd64_image $arm64_image | |
| done | |