Skip to content

Commit bcb7d7d

Browse files
committed
add blank template as input
Signed-off-by: Andrew Brandt <[email protected]>
1 parent e1d14e0 commit bcb7d7d

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

action.yaml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ inputs:
1010
token:
1111
description: 'Personal Access Token'
1212
required: true
13+
template:
14+
description: 'Template for Custom Property Fields'
15+
required: false
1316

1417
runs:
1518
using: "composite"
@@ -77,34 +80,39 @@ runs:
7780
echo "Full repo-properties.json file is:"
7881
cat repo-properties.json
7982
80-
- name: Convert repo properties JSON to YAML
83+
- name: Convert repo properties to YAML using template
8184
shell: bash
8285
run: |
8386
ORG_NAME=$(cat org-name.txt)
8487
8588
{
8689
echo "org: $ORG_NAME"
8790
echo "repositories:"
88-
jq -r '
91+
jq -r --argfile template ${{ inputs.template }} '
8992
to_entries[] |
9093
.key as $repoName |
94+
.value as $props |
95+
$template as $fields |
9196
(
92-
" - name: \($repoName)" +
97+
" - name: \($repoName)\n" +
9398
(
94-
.value
95-
| map(select(.value != ""))
96-
| if length > 0 then
97-
"\n" + (map(" \(.property_name): \"\(.value)\"") | join("\n"))
98-
else
99-
""
100-
end
99+
$fields
100+
| map(
101+
. as $key |
102+
(
103+
($props | map({(.property_name): .value}) | add)[$key] // ""
104+
| " \($key): \"\(.)\""
105+
)
106+
)
107+
| join("\n")
101108
)
102109
)
103110
' repo-properties.json
104111
} > repo-properties.yaml
105112
106113
echo "YAML written to repo-properties.yaml"
107114
115+
108116

109117
- name: Print out the repo-properties.yaml
110118
shell: bash

0 commit comments

Comments
 (0)