Skip to content

Commit

Permalink
test: different grep method
Browse files Browse the repository at this point in the history
  • Loading branch information
andhreljaKern committed Dec 12, 2024
1 parent 403a117 commit 3aab2ec
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pi/edit_dockerfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 3aab2ec

Please sign in to comment.