Skip to content

Commit 1c4ddb1

Browse files
committed
feat: Add scripts/generate-custom-properties-schema.sh
Signed-off-by: Roger Barker <[email protected]>
1 parent fc45d3c commit 1c4ddb1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
generate_custom_props_file() {
4+
5+
while getopts ":ho:r:n:" opt; do
6+
case $opt in
7+
o) ORG="$OPTARG" ;;
8+
n) NAME="$OPTARG" ;;
9+
h) echo "Usage: generate_custom_props_file [-h] -o ORG [-n FILENAME]"; return 0 ;;
10+
\?) echo "Invalid option: -$OPTARG" >&2; return 1 ;;
11+
:) echo "Option -$OPTARG requires an argument." >&2; return 2;;
12+
esac
13+
done
14+
15+
if [[ -z "${ORG}" ]]; then
16+
echo "Error: Organization must be specified." >&2
17+
return 3
18+
fi
19+
20+
NAME=${NAME:-"custom_props.json"}
21+
22+
echo "{" > "${NAME}"
23+
echo " \"properties\":" >> "${NAME}"
24+
gh api /orgs/"${ORG}"/properties/schema | jq -r 'del(.[]|.["url","source_type"])' >> "${NAME}"
25+
echo "}" >> "${NAME}"
26+
27+
cat "${NAME}" | jq . > custom_props.json.tmp
28+
mv custom_props.json.tmp "${NAME}"
29+
}
30+
31+
generate_custom_props_file "$@"
32+

0 commit comments

Comments
 (0)