Fix ssh usage for bake builds

This commit is contained in:
estebanthi
2026-01-05 12:56:52 +01:00
parent 65e2336237
commit 91ab1aaac0

View File

@@ -107,6 +107,10 @@ jobs:
if [ -n "${SSH_AUTH_SOCK:-}" ]; then
SSH_FLAGS+=(--ssh default)
fi
SSH_BAKE_JSON="null"
if [ -n "${SSH_AUTH_SOCK:-}" ]; then
SSH_BAKE_JSON='["default"]'
fi
RAW_REF="${{ github.ref }}"
SHA_FULL="${{ github.sha }}"
@@ -187,6 +191,7 @@ jobs:
--arg target "$TARGET" \
--argjson tags "$TAGS_JSON" \
--argjson args "$BUILD_ARGS_JSON" \
--argjson ssh "$SSH_BAKE_JSON" \
--arg cache_ref "$CACHE_REF" \
'{
context: $context,
@@ -194,6 +199,7 @@ jobs:
tags: $tags,
args: $args
}
+ (if ($ssh != null) then {ssh: $ssh} else {} end)
+ (if ($target != "" and $target != "null") then {target: $target} else {} end)
+ (if ($cache_ref != "") then {"cache-from": ["type=registry,ref=" + $cache_ref], "cache-to": ["type=registry,ref=" + $cache_ref + ",mode=max"]} else {} end)')
@@ -205,7 +211,7 @@ jobs:
BAKE_FILE=$(mktemp)
echo "$BAKE_JSON" > "$BAKE_FILE"
docker buildx bake --file "$BAKE_FILE" --push "${SSH_FLAGS[@]}"
docker buildx bake --file "$BAKE_FILE" --push
rm -f "$BAKE_FILE"
while read -r img; do