From 5d2bbfe7ff266b3de6f9f9445d50f2f637d3b367 Mon Sep 17 00:00:00 2001 From: koplo199 <85577251+koplo199@users.noreply.github.com> Date: Sun, 18 Dec 2022 22:13:20 +0100 Subject: [PATCH] Handle empty file case correctly --- input_files/update_yml_entries.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/input_files/update_yml_entries.sh b/input_files/update_yml_entries.sh index 17186eba..95031273 100755 --- a/input_files/update_yml_entries.sh +++ b/input_files/update_yml_entries.sh @@ -16,7 +16,8 @@ GITHUB_ENV=${GITHUB_ENV-/dev/null} command_wo_sub="{\"$component_name\": {\"Category\":\"$category\", \"Channel\": \"$channel\", \"Date\": \"$created_at\"}}" command_w_sub="{\"$component_name\": {\"Category\":\"$category\", \"Sub-category\":\"$subcategory\", \"Channel\": \"$channel\", \"Date\": \"$created_at\"}}" -if ! [ -f "$filename" ]; then +empty_file=$(yq "." $filename) +if ! [ -f "$filename" ] || [ -z "$empty_file" ]; then touch $filename if [ -z "$subcategory" ]; then yq -n -i -y "$command_wo_sub" $filename