8989 id : metadata
9090 with :
9191 images : ${{ needs.sanitize-image-name.outputs.fully-qualified-image-name }}
92- # Generate image LABEL for devcontainer.metadata
93- # the sed expression is a workaround for quotes being eaten in arrays (e.g. ["x", "y", "z"] -> ["x",y,"z"])
94- - run : echo "metadata=$(jq -cj '[.]' ".devcontainer/${CONTAINER_FLAVOR}/devcontainer-metadata-vscode.json" | sed 's/,"/, "/g')" >> "$GITHUB_OUTPUT"
92+ - name : Generate image LABEL for devcontainer.metadata
93+ run : |
94+ set -Eeuo pipefail
95+
96+ if ([ -z "${DEVCONTAINER_METADATA:-}" ] || [ ! -f "${DEVCONTAINER_METADATA}" ]); then
97+ echo "devcontainer-metadata input not set or file does not exist, skipping devcontainer.metadata label"
98+ echo "metadata=" >> "$GITHUB_OUTPUT"
99+ exit 0
100+ fi
101+
102+ # the sed expression is a workaround for quotes being eaten in arrays (e.g. ["x", "y", "z"] -> ["x",y,"z"])
103+ echo "metadata=devcontainer.metadata\=$(jq -cj '[.]' "${DEVCONTAINER_METADATA}" | sed 's/,"/, "/g')" >> "$GITHUB_OUTPUT"
104+ env :
105+ DEVCONTAINER_METADATA : ${{ inputs.devcontainer-metadata }}
95106 id : devcontainer-metadata
96107 - run : echo "git-commit-epoch=$(git log -1 --pretty=%ct)" >> "$GITHUB_OUTPUT"
97108 id : devcontainer-epoch
@@ -107,7 +118,7 @@ jobs:
107118 tags : ${{ needs.sanitize-image-name.outputs.fully-qualified-image-name }}
108119 labels : |
109120 ${{ steps.metadata.outputs.labels }}
110- devcontainer.metadata= ${{ steps.devcontainer-metadata.outputs.metadata }}
121+ ${{ steps.devcontainer-metadata.outputs.metadata }}
111122 annotations : ${{ steps.metadata.outputs.annotations }}
112123 sbom : true
113124 outputs : type=image,push-by-digest=true,name-canonical=true
0 commit comments