Simplify webhook logic

This commit is contained in:
Pau RE
2024-06-20 13:17:32 +02:00
committed by GitHub
parent cf5f0ada3b
commit d5e4211287
+14 -22
View File
@@ -5,9 +5,9 @@ set -e
# Possible actions: error, pre-backup, post-backup
ACTION="${1}"
if [ "${WEBHOOK_URL}" != "**None**" ]; then
case "${ACTION}" in
"error")
case "${ACTION}" in
"error")
if [ "${WEBHOOK_URL}" != "**None**" ]; then
echo "Execute error webhook call to ${WEBHOOK_URL}"
curl --request POST \
--url "${WEBHOOK_URL}" \
@@ -16,25 +16,7 @@ if [ "${WEBHOOK_URL}" != "**None**" ]; then
--max-time 10 \
--retry 5 \
${WEBHOOK_EXTRA_ARGS}
;;
# "pre-backup")
# echo "Nothing to do"
# ;;
"post-backup")
echo "Execute post-backup webhook call to ${WEBHOOK_URL}"
curl --request POST \
--url "${WEBHOOK_URL}" \
--header 'Content-Type: application/json' \
--data '{"status": "post-backup"}' \
--max-time 10 \
--retry 5 \
${WEBHOOK_EXTRA_ARGS}
;;
esac
fi
case "${ACTION}" in
"error")
fi
if [ "${WEBHOOK_ERROR_URL}" != "**None**" ]; then
echo "Execute error webhook call to ${WEBHOOK_ERROR_URL}"
curl --request POST \
@@ -61,6 +43,16 @@ case "${ACTION}" in
;;
"post-backup")
if [ "${WEBHOOK_URL}" != "**None**" ]; then
echo "Execute post-backup webhook call to ${WEBHOOK_URL}"
curl --request POST \
--url "${WEBHOOK_URL}" \
--header 'Content-Type: application/json' \
--data '{"status": "post-backup"}' \
--max-time 10 \
--retry 5 \
${WEBHOOK_EXTRA_ARGS}
fi
if [ "${WEBHOOK_POST_BACKUP_URL}" != "**None**" ]; then
echo "Execute post-backup webhook call to ${WEBHOOK_POST_BACKUP_URL}"
curl --request POST \