Update GHA scripts to use `bashbrew-buildkit-env-setup.sh`

If our DOI checkout includes the new `bashbrew-buildkit-env-setup.sh` script, we should use it to set up our buildkit-related environment variables.
This commit is contained in:
Tianon Gravi 2023-03-08 14:48:21 -08:00
parent 296033e201
commit 044742f698
1 changed files with 30 additions and 2 deletions

View File

@ -148,6 +148,19 @@ done
strategy="$(
for tag in "${order[@]}"; do
# envObjectToGitHubEnvFileJQ converts from the output of ~/oi/.bin/bashbrew-buildkit-env-setup.sh into what GHA expects in $GITHUB_ENV
# (in a separate env to make embedding/quoting easier inside this sub-jq that generates JSON that embeds shell scripts)
envObjectToGitHubEnvFileJQ='
to_entries | map(
(.key | if test("[^a-zA-Z0-9_]+") then
error("invalid env key: \(.)")
else . end)
+ "="
+ (.value | if test("[\r\n]+") then
error("invalid env value: \(.)")
else . end)
) | join("\n")
' \
jq -c '
.meta += {
froms: (
@ -176,8 +189,23 @@ strategy="$(
),
"git clone --depth 1 https://github.com/docker-library/official-images.git -b master ~/oi",
# https://github.com/docker-library/bashbrew/pull/43
"echo BASHBREW_BUILDKIT_SYNTAX=\"$(< ~/oi/.bashbrew-buildkit-syntax)\" >> \"$GITHUB_ENV\"",
(
"# https://github.com/docker-library/bashbrew/pull/43",
if ([ .meta.entries[].builder ] | index("buildkit")) then
# https://github.com/docker-library/bashbrew/pull/70#issuecomment-1461033890 (we need to _not_ set BASHBREW_ARCH here)
"if [ -x ~/oi/.bin/bashbrew-buildkit-env-setup.sh ]; then",
"\t# https://github.com/docker-library/official-images/pull/14212",
"\tbuildkitEnvs=\"$(~/oi/.bin/bashbrew-buildkit-env-setup.sh)\"",
"\tjq <<<\"$buildkitEnvs\" -r \(env.envObjectToGitHubEnvFileJQ | @sh) | tee -a \"$GITHUB_ENV\"",
"else",
"\tBASHBREW_BUILDKIT_SYNTAX=\"$(< ~/oi/.bashbrew-buildkit-syntax)\"; export BASHBREW_BUILDKIT_SYNTAX",
"\tprintf \"BASHBREW_BUILDKIT_SYNTAX=%q\\n\" \"$BASHBREW_BUILDKIT_SYNTAX\" >> \"$GITHUB_ENV\"",
"fi",
empty
else
empty
end
),
"# create a dummy empty image/layer so we can --filter since= later to get a meaningful image list",
"{ echo FROM " + (