Skip to content

Commit fdf2cfa

Browse files
committed
clean up the conversion step
Signed-off-by: Andrew Brandt <[email protected]>
1 parent 23e5734 commit fdf2cfa

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

action.yaml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,32 @@ runs:
7777
echo "Full repo-properties.json file is:"
7878
cat repo-properties.json
7979
80-
- name: Convert JSON to formatted YAML
80+
- name: Convert repo properties JSON to YAML
8181
shell: bash
8282
run: |
8383
ORG_NAME=$(cat org-name.txt)
84-
echo "org: $ORG_NAME" > repo-properties.yaml
85-
echo "repositories:" >> repo-properties.yaml
86-
87-
jq -r 'to_entries[] |
88-
.key as $repoName |
89-
" - name: \($repoName)\n last-date-modified: \"\"\n" +
90-
(.value | map(" \(.property_name): \"\(.value)\"") | join("\n"))' repo-properties.json >> repo-properties.yaml
91-
84+
85+
{
86+
echo "org: $ORG_NAME"
87+
echo "repositories:"
88+
jq -r '
89+
to_entries[] |
90+
.key as $repoName |
91+
(
92+
" - name: \($repoName)" +
93+
(
94+
.value
95+
| map(select(.value != "")) # skip blank-value fields
96+
| if length > 0 then
97+
"\n" + map(" \(.property_name): \"\(.value)\"") | join("\n")
98+
else
99+
""
100+
end
101+
)
102+
)
103+
' repo-properties.json
104+
} > repo-properties.yaml
105+
92106
echo "YAML written to repo-properties.yaml"
93107
94108
- name: Print out the repo-properties.yaml

0 commit comments

Comments
 (0)