forked from openSIL/openSIL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.sh
More file actions
30 lines (29 loc) · 677 Bytes
/
Copy pathjson.sh
File metadata and controls
30 lines (29 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# This is script that parses input from http report feed variables into json formatted string
# It is used to populate file that Github actions read and populate review board screen
# for in line review of automated CI
arr=();
while read x y;
do
arr=("${arr[@]}" $x $y)
done
vars=(${arr[@]})
len=${#arr[@]}
printf "{"
for (( i=0; i<len; i+=2 ))
do
if [[ ${vars[i+1]} =~ ^[0-9]+$ ]]
then
printf "\"${vars[i]}\": ${vars[i+1]}"
if [ $i -lt $((len-2)) ] ; then
printf ", "
fi
else
printf "\"${vars[i]}\": \"${vars[i+1]}\""
if [ $i -lt $((len-2)) ] ; then
printf ", "
fi
fi
done
printf "}"
echo