Skip to content

Commit 1e5437e

Browse files
authored
Add logging to publish-safe-outputs-node.yml scripts (#39085)
1 parent 54ad1f8 commit 1e5437e

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/publish-safe-outputs-node.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ jobs:
3737
run: |
3838
set -euo pipefail
3939
40+
echo "Fetching metadata for ${NODE_IMAGE_TAG} from ${METADATA_URL}"
4041
metadata=$(curl -fsSL "$METADATA_URL")
42+
echo "Metadata fetched successfully"
43+
4144
digest=$(printf '%s' "$metadata" | jq -r '.images[] | select(.os == "linux" and .architecture == "amd64") | .digest' | head -n 1)
4245
last_updated=$(printf '%s' "$metadata" | jq -r '.last_updated')
4346
47+
echo "Resolved linux/amd64 digest: ${digest}"
48+
echo "Upstream last_updated: ${last_updated}"
49+
4450
if [ -z "$digest" ] || [ "$digest" = "null" ] || [ -z "$last_updated" ] || [ "$last_updated" = "null" ]; then
4551
echo "Failed to resolve node:lts-alpine metadata"
4652
exit 1
@@ -61,6 +67,10 @@ jobs:
6167
6268
short_digest=$(printf '%s' "$digest" | sed 's/^sha256://' | cut -c1-12)
6369
70+
echo "Upstream image age: $((age_seconds / 86400)) day(s) (cooldown window: ${COOLDOWN_DAYS} day(s))"
71+
echo "In cooldown: ${in_cooldown}"
72+
echo "Short digest: ${short_digest}"
73+
6474
echo "base_image=${NODE_IMAGE_TAG}@${digest}" >> "$GITHUB_OUTPUT"
6575
echo "digest=$digest" >> "$GITHUB_OUTPUT"
6676
echo "short_digest=$short_digest" >> "$GITHUB_OUTPUT"
@@ -73,7 +83,10 @@ jobs:
7383
run: |
7484
set -euo pipefail
7585
76-
hash=$(sha256sum actions/setup/js/Dockerfile.safe-outputs-mcp | cut -d' ' -f1)
86+
dockerfile="actions/setup/js/Dockerfile.safe-outputs-mcp"
87+
echo "Computing SHA-256 hash of ${dockerfile}"
88+
hash=$(sha256sum "$dockerfile" | cut -d' ' -f1)
89+
echo "Dockerfile hash: ${hash}"
7790
7891
echo "hash=$hash" >> "$GITHUB_OUTPUT"
7992
@@ -96,11 +109,15 @@ jobs:
96109
existing_revision=""
97110
existing_dockerfile_hash=""
98111
112+
echo "Attempting to pull ${IMAGE_NAME}:latest"
99113
if docker pull "$IMAGE_NAME:latest" >/dev/null 2>&1; then
100114
image_exists=true
115+
echo "Image pulled successfully; extracting labels"
101116
existing_digest=$(docker inspect "$IMAGE_NAME:latest" --format '{{ index .Config.Labels "org.opencontainers.image.base.digest" }}' 2>/dev/null || true)
102117
existing_revision=$(docker inspect "$IMAGE_NAME:latest" --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' 2>/dev/null || true)
103118
existing_dockerfile_hash=$(docker inspect "$IMAGE_NAME:latest" --format '{{ index .Config.Labels "io.github.gh-aw.safe-outputs.dockerfile-hash" }}' 2>/dev/null || true)
119+
else
120+
echo "Image ${IMAGE_NAME}:latest not found in registry"
104121
fi
105122
106123
if [ "$existing_digest" = "<no value>" ]; then
@@ -113,6 +130,11 @@ jobs:
113130
existing_dockerfile_hash=""
114131
fi
115132
133+
echo "Image exists: ${image_exists}"
134+
echo "Published base digest: ${existing_digest:-none}"
135+
echo "Published revision: ${existing_revision:-none}"
136+
echo "Published Dockerfile hash: ${existing_dockerfile_hash:-none}"
137+
116138
echo "image_exists=$image_exists" >> "$GITHUB_OUTPUT"
117139
echo "base_digest=$existing_digest" >> "$GITHUB_OUTPUT"
118140
echo "revision=$existing_revision" >> "$GITHUB_OUTPUT"
@@ -131,6 +153,15 @@ jobs:
131153
run: |
132154
set -euo pipefail
133155
156+
echo "--- Decision inputs ---"
157+
echo "Image exists: ${IMAGE_EXISTS}"
158+
echo "In cooldown: ${IN_COOLDOWN} (window: ${COOLDOWN_DAYS} day(s))"
159+
echo "Current upstream digest: ${CURRENT_BASE_DIGEST}"
160+
echo "Published base digest: ${EXISTING_BASE_DIGEST:-none}"
161+
echo "Current Dockerfile hash: ${CURRENT_DOCKERFILE_HASH}"
162+
echo "Published Dockerfile hash: ${EXISTING_DOCKERFILE_HASH:-none}"
163+
echo "--- Evaluating conditions ---"
164+
134165
should_push=false
135166
reason="No changes detected"
136167
@@ -147,6 +178,9 @@ jobs:
147178
reason="Container Dockerfile changed"
148179
fi
149180
181+
echo "Decision: should_push=${should_push}"
182+
echo "Reason: ${reason}"
183+
150184
echo "should_push=$should_push" >> "$GITHUB_OUTPUT"
151185
echo "reason=$reason" >> "$GITHUB_OUTPUT"
152186

0 commit comments

Comments
 (0)