Skip to content

Commit

Permalink
make previous build check fail gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
antheas committed Jul 31, 2024
1 parent 3753005 commit b56ab9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion 3_chunk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@ PREV_MANIFEST=${PREV_MANIFEST:=./${PREV_NAME}.manifest.json}

if [ -n "$PREV_REF" ]; then
echo "PREV_REF is set, downloading manifest"
skopeo inspect docker://${PREV_REF} > $PREV_MANIFEST
for i in $(seq 1 5); do
skopeo inspect docker://${PREV_REF} > $PREV_MANIFEST && break
echo "Failed to download previous manifest, retrying in 3 seconds"
sleep 3
done

if [ ! -f "$PREV_MANIFEST" ]; then
echo "############################################"
echo "ERROR: Failed to download previous manifest"
if [ -n "$PREV_REF_FAIL" ]; then
echo "Failing build due to PREV_REF_FAIL being set."
exit 1
else
echo "Continuing build without previous manifest"
fi
fi
fi

# Try to use venv if it exists for
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ inputs:
description: |
The previous image reference, if any. Used for versioning
the current image and to avoid layer shifts (important; may be skipped).
prev-ref-fail:
description: |
If set, fail if the previous image reference is not found.
max-layers:
description: |
The number of layers (chunks) the output image will have.
Expand Down Expand Up @@ -119,6 +122,7 @@ runs:
-e VERSION="${{ inputs.version }}" \
-e VERSION_FN="/workspace/version.txt" \
-e OUT_REF="oci:$OUT_NAME" \
-e PREV_REF_FAIL="${{ inputs.prev-ref-fail }}" \
-u 0:0 \
${{ inputs.rechunk }} \
/sources/rechunk/3_chunk.sh
Expand Down

0 comments on commit b56ab9f

Please sign in to comment.