@@ -242,15 +242,32 @@ jobs:
242242 fi
243243 done < <(jq -r '.source_refs | to_entries[]? | [.key, .value] | @tsv' <<< "$entry")
244244
245+ build_arg_lines=$(jq -r \
246+ 'to_entries[] | "\(.key)=\(.value)"' <<< "$build_args")
247+ source_labels=$(jq -r \
248+ 'to_entries[] | (.key | gsub("_"; "-")) as $label |
249+ "io.flagscale.source.\($label).revision=\(.value.revision)\n" +
250+ "io.flagscale.source.\($label).selector=\(.value.selector)"' \
251+ <<< "$source_metadata")
252+ source_summary=$(jq -r \
253+ 'to_entries[] |
254+ "| `\(.key)` | `\(.value.selector)` | `\(.value.revision)` |"' \
255+ <<< "$source_metadata")
245256 candidate="${registry}/${image_name}:${short_sha}-${PLATFORM}-${target}"
246257 entry=$(jq -c \
247258 --arg registry "$registry" \
248259 --arg image "$candidate" \
260+ --arg build_arg_lines "$build_arg_lines" \
261+ --arg source_labels "$source_labels" \
262+ --arg source_summary "$source_summary" \
249263 --argjson build_args "$build_args" \
250264 --argjson resolved_sources "$source_metadata" \
251265 '. + {
252266 registry: $registry,
253267 image: $image,
268+ build_arg_lines: $build_arg_lines,
269+ source_labels: $source_labels,
270+ source_summary: $source_summary,
254271 build_args: $build_args,
255272 resolved_sources: $resolved_sources
256273 }' <<< "$entry")
@@ -338,26 +355,6 @@ jobs:
338355 echo "https_proxy=${https_proxy:-${HTTPS_PROXY:-}}" >> "$GITHUB_OUTPUT"
339356 echo "no_proxy=${no_proxy:-${NO_PROXY:-}}" >> "$GITHUB_OUTPUT"
340357
341- - name : Resolve build arguments and labels
342- id : metadata
343- shell : bash
344- env :
345- BUILD_ARGS_JSON : ${{ toJSON(matrix.build_args) }}
346- SOURCES_JSON : ${{ toJSON(matrix.resolved_sources) }}
347- run : |
348- set -euo pipefail
349- {
350- echo 'args<<EOF_BUILD_ARGS'
351- jq -r 'to_entries[] | "\(.key)=\(.value)"' <<< "$BUILD_ARGS_JSON"
352- echo 'EOF_BUILD_ARGS'
353- echo 'labels<<EOF_SOURCE_LABELS'
354- jq -r 'to_entries[] | (.key | gsub("_"; "-")) as $label |
355- "io.flagscale.source.\($label).revision=\(.value.revision)\n" +
356- "io.flagscale.source.\($label).selector=\(.value.selector)"' \
357- <<< "$SOURCES_JSON"
358- echo 'EOF_SOURCE_LABELS'
359- } >> "$GITHUB_OUTPUT"
360-
361358 - name : Set up Docker Buildx
362359 uses : docker/setup-buildx-action@v3
363360 with :
@@ -410,7 +407,7 @@ jobs:
410407 no-cache : ${{ inputs.no_cache }}
411408 build-args : |
412409 BASE_IMAGE=${{ matrix.base_image }}
413- ${{ steps.metadata.outputs.args }}
410+ ${{ matrix.build_arg_lines }}
414411 HTTP_PROXY=${{ steps.proxy.outputs.http_proxy }}
415412 HTTPS_PROXY=${{ steps.proxy.outputs.https_proxy }}
416413 NO_PROXY=${{ steps.proxy.outputs.no_proxy }}
@@ -421,7 +418,7 @@ jobs:
421418 org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
422419 org.opencontainers.image.revision=${{ github.event.pull_request.head.sha || github.sha }}
423420 org.opencontainers.image.base.name=${{ matrix.base_image }}
424- ${{ steps.metadata.outputs.labels }}
421+ ${{ matrix.source_labels }}
425422
426423 - name : Wait before build retry
427424 if : steps.build_attempt_1.outcome == 'failure'
@@ -440,7 +437,7 @@ jobs:
440437 no-cache : ${{ inputs.no_cache }}
441438 build-args : |
442439 BASE_IMAGE=${{ matrix.base_image }}
443- ${{ steps.metadata.outputs.args }}
440+ ${{ matrix.build_arg_lines }}
444441 HTTP_PROXY=${{ steps.proxy.outputs.http_proxy }}
445442 HTTPS_PROXY=${{ steps.proxy.outputs.https_proxy }}
446443 NO_PROXY=${{ steps.proxy.outputs.no_proxy }}
@@ -451,7 +448,7 @@ jobs:
451448 org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
452449 org.opencontainers.image.revision=${{ github.event.pull_request.head.sha || github.sha }}
453450 org.opencontainers.image.base.name=${{ matrix.base_image }}
454- ${{ steps.metadata.outputs.labels }}
451+ ${{ matrix.source_labels }}
455452
456453 - name : Run platform post-build contract
457454 if : matrix.validation_script != ''
@@ -501,7 +498,7 @@ jobs:
501498 TASK : ${{ matrix.task }}
502499 IMAGE : ${{ matrix.image }}
503500 BASE_IMAGE : ${{ matrix.base_image }}
504- SOURCES_JSON : ${{ toJSON( matrix.resolved_sources) }}
501+ SOURCE_SUMMARY : ${{ matrix.source_summary }}
505502 REMOTE_DIGEST : ${{ steps.push_image.outputs.digest }}
506503 run : |
507504 set -euo pipefail
@@ -519,13 +516,11 @@ jobs:
519516 echo '- Published digest: `not pushed`'
520517 fi
521518 echo "- Local image ID: \`$local_id\`"
522- if [ "$SOURCES_JSON" != '{}' ]; then
519+ if [ -n "$SOURCE_SUMMARY" ]; then
523520 echo
524521 echo '| Source | Selector | Revision |'
525522 echo '|---|---|---|'
526- jq -r 'to_entries[] |
527- "| `\(.key)` | `\(.value.selector)` | `\(.value.revision)` |"' \
528- <<< "$SOURCES_JSON"
523+ printf '%s\n' "$SOURCE_SUMMARY"
529524 fi
530525 } >> "$GITHUB_STEP_SUMMARY"
531526
0 commit comments