From 3d51150d8bcdf1004bd1a87c6927f7233429a753 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Aug 2024 19:04:05 +1000 Subject: [PATCH] MariaDB operator - add trigger Take the sha from the pushed manifest as the arg to pass to the github mariadb operator. --- master-nonlatent/master.cfg | 49 ++++++++++++++++++++++++++++++ scripts/docker-library-manifest.sh | 3 ++ 2 files changed, 52 insertions(+) diff --git a/master-nonlatent/master.cfg b/master-nonlatent/master.cfg index 83350327..8e19bc41 100644 --- a/master-nonlatent/master.cfg +++ b/master-nonlatent/master.cfg @@ -738,6 +738,55 @@ f_dockerlibrary.addStep( ], ) ) +f_dockerlibrary.addStep( + steps.SetPropertyFromCommand( + name="Extract the last tag created", + command=["cat", "last_tag"], + property="lasttag", + ) +) +f_dockerlibrary.addStep( + steps.SetPropertyFromCommand( + name="Determine sha for the last tag", + command=[ + "bash", + "-xc", + util.Interpolate( + "curl -s https://quay.io/api/v1/repository/mariadb-foundation/mariadb-devel/tag/?filter_tag_name=eq:%(prop:lasttag)s&onlyActiveTags=true | jq -r .tags[0].manifest_digest" + ), + ], + property="lastsha", + ) +) +f_dockerlibrary.addStep( + steps.ShellCommand( + name="gh credentials", + command=[ + "bash", + "-xc", + "gh auth login --with-token < ~/gh_auth", + ], + doStepIf=lambda step: (str(step.getProperty("lastsha")) != ""), + ) +) +f_dockerlibrary.addStep( + steps.ShellCommand( + name="test operator with image", + command=[ + "bash", + "-xc", + util.Interpolate( + "gh workflow run %(kw:testname)s --repo mariadb-operator/mariadb-operator -f mariadb_image=quay.io/mariadb-foundation/mariadb-devel@%(prop:lastsha)s", + testname=lambda step: ( + "test-image-ent.yml" + if "rhel" in str(step.getProperty("parentbuildername")) + else "test-image.yml" + ), + ), + ], + doStepIf=lambda step: (str(step.getProperty("lastsha")) != ""), + ) +) ## f_aix f_aix = util.BuildFactory() diff --git a/scripts/docker-library-manifest.sh b/scripts/docker-library-manifest.sh index 04c3838f..aa89cfd3 100755 --- a/scripts/docker-library-manifest.sh +++ b/scripts/docker-library-manifest.sh @@ -11,6 +11,7 @@ commit=${4:-0} branch=${5:-${master_branch}} prod_environment=${6:-True} +rm -f last_tag # keep in sync with docker-cleanup script if [[ $branch = *pkgtest* ]]; then container_tag=${branch#bb-} @@ -181,8 +182,10 @@ if (($(buildah manifest inspect "$devmanifest" | jq '.manifests | length') >= ex trap 'manifest_image_cleanup "$t"' EXIT if [ "$prod_environment" = "True" ]; then buildah manifest push --all --rm "$devmanifest" "docker://quay.io/mariadb-foundation/mariadb-devel:${container_tag}" + echo "${container_tag}" > last_tag else buildah manifest rm "$devmanifest" + rm -f last_tag fi manifest_image_cleanup "$t"