use dos2unix to clean up gross line endings in echofeed import

This commit is contained in:
John Bowdre 2024-04-13 18:31:19 -05:00
parent fa7f0b3157
commit 8c0e357654
2 changed files with 10 additions and 5 deletions

View file

@ -11,13 +11,15 @@ RUN go mod download && CGO_ENABLED=0 GOOS=linux go build -o /md2gmi
FROM ubuntu:22.04 AS release FROM ubuntu:22.04 AS release
RUN DEBIAN_FRONTEND=noninteractive apt-get update \ RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y uuid-runtime=2.37.2-4ubuntu3.4 \ && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
dos2unix=7.4.2-2 \
uuid-runtime=2.37.2-4ubuntu3.4 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY --from=go-builder /md2gmi /usr/local/bin/md2gmi COPY --from=go-builder /md2gmi /usr/local/bin/md2gmi
COPY convert-dir.sh /usr/local/bin/convert-dir.sh COPY convert.sh /usr/local/bin/convert.sh
RUN chmod +x /usr/local/bin/convert-dir.sh RUN chmod +x /usr/local/bin/convert.sh
WORKDIR /github/workspace WORKDIR /github/workspace
ENTRYPOINT ["/usr/local/bin/convert-dir.sh"] ENTRYPOINT ["/usr/local/bin/convert.sh"]

View file

@ -6,7 +6,7 @@ if [ $# -ne 3 ]; then
exit 1 exit 1
fi fi
# strip trailing slashes from input and output directories # Strip trailing slashes from input and output directories
input_dir="${1%/}" input_dir="${1%/}"
output_dir="${2%/}" output_dir="${2%/}"
processed_dir="${3%/}" processed_dir="${3%/}"
@ -22,6 +22,9 @@ fi
for file in "$input_dir"/*.md; do for file in "$input_dir"/*.md; do
file=$(basename "$file") file=$(basename "$file")
# Convert yucky line endings
dos2unix "$input_dir/$file"
# Extract frontmatter and dump it to YAML file # Extract frontmatter and dump it to YAML file
echo "id: \"urn:uuid:$(uuidgen)\"" > "$output_dir/${file%.md}.yaml" echo "id: \"urn:uuid:$(uuidgen)\"" > "$output_dir/${file%.md}.yaml"
awk '/^---$/{if(seen){exit}else{seen=1;next}} seen' "$input_dir/$file" >> "$output_dir/${file%.md}.yaml" awk '/^---$/{if(seen){exit}else{seen=1;next}} seen' "$input_dir/$file" >> "$output_dir/${file%.md}.yaml"