diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml index ab37575..84a5906 100644 --- a/.gitea/workflows/image.yml +++ b/.gitea/workflows/image.yml @@ -236,29 +236,39 @@ jobs: # Context: this commit of this repository, cloned by kaniko (##: # clone , check out ). The Dockerfile has no COPY, so only it is read. - /kaniko/executor \ + # + # When it finishes the executor has replaced the job container's filesystem with + # the built image and removed /kaniko, so nothing written there (a --digest-file, + # the credential method) can be read back. Take the digest from its + # "Pushed @sha256:" log line into a variable of this shell, which + # needs only builtins by then. + digest="" + while IFS= read -r line; do + printf '%s\n' "$line" + case "$line" in + *"Pushed "*"@sha256:"*) digest="sha256:${line##*@sha256:}"; digest="${digest:0:71}" ;; + esac + done < <(/kaniko/executor \ --context "git://${registry}/${REPO}.git#${REF}#${SHA}" \ --context-sub-path images/molecule-ubuntu2404 \ --dockerfile Dockerfile \ "${dests[@]}" \ - --digest-file /kaniko/digest \ --snapshot-mode=redo \ --cache=false \ --push-retry 3 \ --image-fs-extract-retry 3 \ - --force + --force 2>&1) + wait "$!" - # The filesystem now holds the built image; read and echo are builtins. - read -r digest < /kaniko/digest - read -r method < /kaniko/credential-method - echo "Pushed with credential: $method" + if ! [[ "$digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then + echo "::error::kaniko finished but no pushed image digest was found in its output." + exit 1 + fi echo "Pinned reference: ${image}@${digest}" if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then { echo "### molecule-ubuntu2404 pushed" echo - echo "Credential: ${method}" - echo echo "Pin it by digest: \`${image}@${digest}\`" } >> "$GITHUB_STEP_SUMMARY" || true fi