Skip to content

Commit 9956a71

Browse files
committed
fix: multiple docker edits
1 parent 3db47e0 commit 9956a71

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pi/edit_dockerfile.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PARENT_IMAGE_NAME="refinery-parent-images"
66
RELEASE_TAG=""
77
DOCKER_REGISTRY="kernai"
88
DOCKERFILE="Dockerfile"
9-
HEAD_REF=""
9+
HEAD_REF="parent-image-updates"
1010

1111
while getopts i:l:r:d:h: flag
1212
do
@@ -21,11 +21,19 @@ done
2121

2222
grep "${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}" $DOCKERFILE | while read -r line ; do
2323
PI_EXISTING_TAG=$(echo $line | sed 's|FROM ||g' | cut -d ':' -f 2)
24-
if [ -z $HEAD_REF ]; then
24+
ALREADY_UPDATED=$(echo $PI_EXISTING_TAG | grep $RELEASE_TAG || true)
25+
26+
if [ -z $ALREADY_UPDATED ] && [ -z $HEAD_REF ]; then
2527
PARENT_IMAGE_TYPE=$(echo $PI_EXISTING_TAG | cut -d '-' -f 2-)
26-
else
28+
elif [ -n $ALREADY_UPDATED ] && [ -z $HEAD_REF ]; then
29+
PARENT_IMAGE_TYPE=$(echo $PI_EXISTING_TAG | sed "s|${RELEASE_TAG}-||g")
30+
elif [ -n $HEAD_REF ]; then
2731
PARENT_IMAGE_TYPE=$(echo $PI_EXISTING_TAG | sed "s|${HEAD_REF}-||g")
32+
else
33+
echo "::error::Failed to determine parent image type from tag: ${PI_EXISTING_TAG}"
34+
exit 1
2835
fi
36+
2937
PI_EXISTING_IMAGE="${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}:${PI_EXISTING_TAG}"
3038
PI_NEW_IMAGE="${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}:${RELEASE_TAG}-${PARENT_IMAGE_TYPE}"
3139

0 commit comments

Comments
 (0)