8989 continue
9090 fi
9191
92- templates_files=$(find "$RUNNER_TEMP/old" "$RUNNER_TEMP/new" -maxdepth 2 -name '*.yaml' | grep "$values_dir" | sed -E 's|'"$RUNNER_TEMP"'/(old\|new)/||' | sort | uniq)
92+ templates_files=$(find "$RUNNER_TEMP/old" "$RUNNER_TEMP/new" -maxdepth 2 -name '*.yaml' | grep "/ $values_dir/ " | sed -E 's|'"$RUNNER_TEMP"'/(old\|new)/||' | sort | uniq)
9393 comment_templates_body=""
94+ values_file_suffix=""
95+ on_both_branches="true"
96+ if [ ! -d "$RUNNER_TEMP/old/$values_dir" ]; then
97+ values_file_suffix=" (added)"
98+ on_both_branches="false"
99+ elif [ ! -d "$RUNNER_TEMP/new/$values_dir" ]; then
100+ values_file_suffix=" (removed)"
101+ on_both_branches="false"
102+ fi
94103
95104 while read -r templates_file; do
96105 current_file="$(basename "$templates_file")"
@@ -99,40 +108,34 @@ jobs:
99108 fi
100109
101110 if [ ! -f "$RUNNER_TEMP/old/$templates_file" ]; then
102- api_version=$(yq '.apiVersion' "$RUNNER_TEMP/new/$templates_file")
103111 kind=$(yq '.kind' "$RUNNER_TEMP/new/$templates_file")
104112 name=$(yq '.metadata.name' "$RUNNER_TEMP/new/$templates_file")
105113 namespace=$(yq '.metadata.namespace' "$RUNNER_TEMP/new/$templates_file")
106- metadata=$(yq '.metadata' "$RUNNER_TEMP/new/$templates_file")
107- comment_templates_body+="@@ $current_file @@\n"
108- comment_templates_body+="# $api_version/$kind/$namespace/$name\n"
109- comment_templates_body+="! + one file added - the full content of the file is available in ${ARTIFACT_URL}\n"
110- comment_templates_body+="+ apiVersion: $api_version\n"
111- comment_templates_body+="+ kind: $kind\n"
112- comment_templates_body+="+ metadata:\n"
113- while IFS= read -r line; do
114- comment_templates_body+="+ $line\n"
115- done <<< "$metadata"
116- comment_templates_body+="\n\n"
114+ if [ "$on_both_branches" == "true" ]; then
115+ comment_templates_body+="@@ $kind/$namespace/$name @@\n"
116+ while IFS= read -r line; do
117+ comment_templates_body+="+ $line\n"
118+ done < "$RUNNER_TEMP/new/$templates_file"
119+ comment_templates_body+="\n\n"
120+ else
121+ comment_templates_body+="$kind/$namespace/$name added\n"
122+ fi
117123 continue
118124 fi
119125
120126 if [ ! -f "$RUNNER_TEMP/new/$templates_file" ]; then
121- api_version=$(yq '.apiVersion' "$RUNNER_TEMP/old/$templates_file" )
122127 kind=$(yq '.kind' "$RUNNER_TEMP/old/$templates_file")
123128 name=$(yq '.metadata.name' "$RUNNER_TEMP/old/$templates_file")
124129 namespace=$(yq '.metadata.namespace' "$RUNNER_TEMP/old/$templates_file")
125- metadata=$(yq '.metadata' "$RUNNER_TEMP/old/$templates_file")
126- comment_templates_body+="@@ $current_file @@\n"
127- comment_templates_body+="# $api_version/$kind/$namespace/$name\n"
128- comment_templates_body+="! - one file removed\n"
129- comment_templates_body+="- apiVersion: $api_version\n"
130- comment_templates_body+="- kind: $kind\n"
131- comment_templates_body+="- metadata:\n"
132- while IFS= read -r line; do
133- comment_templates_body+="- $line\n"
134- done <<< "$metadata"
135- comment_templates_body+="\n\n"
130+ if [ "$on_both_branches" == "true" ]; then
131+ comment_templates_body+="@@ $kind/$namespace/$name @@\n"
132+ while IFS= read -r line; do
133+ comment_templates_body+="- $line\n"
134+ done < "$RUNNER_TEMP/old/$templates_file"
135+ comment_templates_body+="\n\n"
136+ else
137+ comment_templates_body+="$kind/$namespace/$name removed\n"
138+ fi
136139 continue
137140 fi
138141
@@ -144,18 +147,16 @@ jobs:
144147 exit 1
145148 fi
146149
147- api_version=$(yq '.apiVersion' "$RUNNER_TEMP/new/$templates_file")
148150 kind=$(yq '.kind' "$RUNNER_TEMP/new/$templates_file")
149151 name=$(yq '.metadata.name' "$RUNNER_TEMP/new/$templates_file")
150152 namespace=$(yq '.metadata.namespace' "$RUNNER_TEMP/new/$templates_file")
151- resource_metadata="# $api_version/$kind/$namespace/$name"
152- comment_templates_body+=$(sed -e "1d" -e "/^@@/a$resource_metadata" <<< "$dyff_detail")
153+ comment_templates_body+=$(sed -e '/^!/d' -e "s|^@@\(.*\)@@|@@ $kind/$namespace/$name -\1@@|" <<< "$dyff_detail")
153154 comment_templates_body+="\n\n\n"
154155 fi
155156 done <<< "$templates_files"
156157
157158 if [[ -n "$comment_templates_body" ]]; then
158- comment_body+="<details><summary><b>$values_dir.yaml</b></summary>\n"
159+ comment_body+="<details><summary><b>$values_dir.yaml$values_file_suffix </b></summary>\n"
159160 comment_body+='\n```diff\n'
160161 comment_body+="$comment_templates_body"
161162 comment_body+='```\n'
@@ -166,8 +167,11 @@ jobs:
166167
167168 if [ -z "$comment_body" ]; then
168169 comment_body="No changes in rendered templates"
170+ else
171+ header+="Full contents of manifests and dyffs are available in ${ARTIFACT_URL}\n\n"
169172 fi
170173
174+
171175 echo -e "$header$comment_body" | tee "$RUNNER_TEMP/dyff-output.md"
172176 echo "pr-number=$PR_NUMBER" | tee "$RUNNER_TEMP/pr-number.txt"
173177
0 commit comments