Example from a script I wrote. Modify as needed
# Records a decision in DECISION_FILE_PATH
#
# The contents of this file can then later be used by our CI job to take
# appropriate action.
function decision {
local environemnt="$1"
local cluster="$2"
local action="$3"
local reason="$4"
# Initialise file to the empty list if it does not exist.
if [[ ! -f ${DECISION_FILE_PATH} ]]; then
echo "[]" > $DECISION_FILE_PATH
fi
decisions=$(cat "${DECISION_FILE_PATH}")
decision="{
\"environment\": \"${environemnt}\",
\"cluster\": \"${cluster}\",
\"action\": \"${action}\",
\"reason\": \"${reason}\"
}"
# Add decision object to array
echo "${decisions}" | jq ". += [$decision]" > "${DECISION_FILE_PATH}"
}