From 3aab2ecf8f937e88458cee99a5c0568813c08555 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 12 Dec 2024 17:40:17 +0100 Subject: [PATCH] test: different grep method --- pi/edit_dockerfile.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pi/edit_dockerfile.sh b/pi/edit_dockerfile.sh index 926df5e..d8b2720 100644 --- a/pi/edit_dockerfile.sh +++ b/pi/edit_dockerfile.sh @@ -19,22 +19,22 @@ do esac done -line=$(grep "${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}:v.*-${PARENT_IMAGE_TYPE}" $DOCKERFILE) +grep "${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}:v.*-${PARENT_IMAGE_TYPE}" $DOCKERFILE | while read -r line ; do + PI_EXISTING_TAG=$(echo $line | sed 's|FROM ||g' | cut -d ':' -f 2) + PI_EXISTING_IMAGE="${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}:${PI_EXISTING_TAG}" + PI_NEW_IMAGE="${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}:${RELEASE_TAG}-${PARENT_IMAGE_TYPE}" -PI_EXISTING_TAG=$(echo $line | sed 's|FROM ||g' | cut -d ':' -f 2) -PI_EXISTING_IMAGE="${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}:${PI_EXISTING_TAG}" -PI_NEW_IMAGE="${DOCKER_REGISTRY}/${PARENT_IMAGE_NAME}:${RELEASE_TAG}-${PARENT_IMAGE_TYPE}" + echo "PI_EXISTING_TAG = $PI_EXISTING_TAG" + echo "PI_EXISTING_IMAGE = $PI_EXISTING_IMAGE" + echo "PI_NEW_IMAGE = $PI_NEW_IMAGE" -echo "PI_EXISTING_TAG = $PI_EXISTING_TAG" -echo "PI_EXISTING_IMAGE = $PI_EXISTING_IMAGE" -echo "PI_NEW_IMAGE = $PI_NEW_IMAGE" + echo "Dockerfile before update:" + cat ${DOCKERFILE} + sed "s|${PI_EXISTING_IMAGE}|${PI_NEW_IMAGE}|g" ${DOCKERFILE} > ${DOCKERFILE}.tmp && mv ${DOCKERFILE}.tmp ${DOCKERFILE} -echo "Dockerfile before update:" -cat ${DOCKERFILE} -sed 's|'${PI_EXISTING_IMAGE}'|'${PI_NEW_IMAGE}'|g' ${DOCKERFILE} > ${DOCKERFILE}.tmp && mv ${DOCKERFILE}.tmp ${DOCKERFILE} - -echo "sed output:" -sed 's|'${PI_EXISTING_IMAGE}'|'${PI_NEW_IMAGE}'|g' ${DOCKERFILE} + echo "sed output:" + sed "s|${PI_EXISTING_IMAGE}|${PI_NEW_IMAGE}|g" ${DOCKERFILE} +done echo "Dockerfile after update:" cat ${DOCKERFILE} echo "::notice::Dockerfile updated with new image: ${PI_NEW_IMAGE}" \ No newline at end of file