Skip to content

Commit 6e7f235

Browse files
authored
Merge pull request #70 from infosiftr/bashbrew-buildkit-envs
Update GHA scripts to use `bashbrew-buildkit-envs.sh`
2 parents f7f54c2 + 044742f commit 6e7f235

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

scripts/github-actions/generate.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,19 @@ done
148148

149149
strategy="$(
150150
for tag in "${order[@]}"; do
151+
# envObjectToGitHubEnvFileJQ converts from the output of ~/oi/.bin/bashbrew-buildkit-env-setup.sh into what GHA expects in $GITHUB_ENV
152+
# (in a separate env to make embedding/quoting easier inside this sub-jq that generates JSON that embeds shell scripts)
153+
envObjectToGitHubEnvFileJQ='
154+
to_entries | map(
155+
(.key | if test("[^a-zA-Z0-9_]+") then
156+
error("invalid env key: \(.)")
157+
else . end)
158+
+ "="
159+
+ (.value | if test("[\r\n]+") then
160+
error("invalid env value: \(.)")
161+
else . end)
162+
) | join("\n")
163+
' \
151164
jq -c '
152165
.meta += {
153166
froms: (
@@ -176,8 +189,23 @@ strategy="$(
176189
),
177190
"git clone --depth 1 https://github.com/docker-library/official-images.git -b master ~/oi",
178191
179-
# https://github.com/docker-library/bashbrew/pull/43
180-
"echo BASHBREW_BUILDKIT_SYNTAX=\"$(< ~/oi/.bashbrew-buildkit-syntax)\" >> \"$GITHUB_ENV\"",
192+
(
193+
"# https://github.com/docker-library/bashbrew/pull/43",
194+
if ([ .meta.entries[].builder ] | index("buildkit")) then
195+
# https://github.com/docker-library/bashbrew/pull/70#issuecomment-1461033890 (we need to _not_ set BASHBREW_ARCH here)
196+
"if [ -x ~/oi/.bin/bashbrew-buildkit-env-setup.sh ]; then",
197+
"\t# https://github.com/docker-library/official-images/pull/14212",
198+
"\tbuildkitEnvs=\"$(~/oi/.bin/bashbrew-buildkit-env-setup.sh)\"",
199+
"\tjq <<<\"$buildkitEnvs\" -r \(env.envObjectToGitHubEnvFileJQ | @sh) | tee -a \"$GITHUB_ENV\"",
200+
"else",
201+
"\tBASHBREW_BUILDKIT_SYNTAX=\"$(< ~/oi/.bashbrew-buildkit-syntax)\"; export BASHBREW_BUILDKIT_SYNTAX",
202+
"\tprintf \"BASHBREW_BUILDKIT_SYNTAX=%q\\n\" \"$BASHBREW_BUILDKIT_SYNTAX\" >> \"$GITHUB_ENV\"",
203+
"fi",
204+
empty
205+
else
206+
empty
207+
end
208+
),
181209
182210
"# create a dummy empty image/layer so we can --filter since= later to get a meaningful image list",
183211
"{ echo FROM " + (

0 commit comments

Comments
 (0)