GHA: update tags #116
This file contains 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@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
- name: Getting image tag | |
id: tag | |
run: | | |
echo tag=${GITHUB_REF##*/} | tee -a $GITHUB_OUTPUT | |
- name: setup docker buildx | |
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0 | |
- name: quay login | |
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.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) | |
image=$(echo $f/$tag | sed -e 's_/_-ci:_; s_/_-_g') | |
src_image="quay.io/lvh-images/$(echo $f/$tag | 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:/:/') | |
echo -e "\033[0;32m${src_image} -> ${dst_image}\e[0m"; | |
docker pull $src_image | |
docker tag $src_image $dst_image | |
docker push $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"; | |
docker tag $src_image $dst_prod_image | |
docker push $dst_prod_image | |
docker image rmi $dst_prod_image | |
fi | |
docker image rmi $src_image $dst_image | |
done |