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