From 4998e2ee76ab60a23075d5590485dedc66591546 Mon Sep 17 00:00:00 2001 From: Arthur Bodera Date: Wed, 19 Jun 2024 10:08:59 +1000 Subject: [PATCH] Add support for granular webhooks in 00-webhook --- hooks/00-webhook | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/hooks/00-webhook b/hooks/00-webhook index 869adab..f6a9b33 100755 --- a/hooks/00-webhook +++ b/hooks/00-webhook @@ -32,3 +32,45 @@ if [ "${WEBHOOK_URL}" != "**None**" ]; then ;; esac fi + +case "${ACTION}" in + "error") + if [ "${WEBHOOK_ERROR_URL}" != "**None**" ]; then + echo "Execute error webhook call to ${WEBHOOK_ERROR_URL}" + curl --request POST \ + --url "${WEBHOOK_ERROR_URL}" \ + --header 'Content-Type: application/json' \ + --data '{"status": "error"}' \ + --max-time 10 \ + --retry 5 \ + ${WEBHOOK_EXTRA_ARGS} + fi + ;; + + "pre-backup") + if [ "${WEBHOOK_PRE_BACKUP_URL}" != "**None**" ]; then + echo "Execute pre-backup webhook call to ${WEBHOOK_PRE_BACKUP_URL}" + curl --request POST \ + --url "${WEBHOOK_PRE_BACKUP_URL}" \ + --header 'Content-Type: application/json' \ + --data '{"status": "error"}' \ + --max-time 10 \ + --retry 5 \ + ${WEBHOOK_EXTRA_ARGS} + fi + ;; + + "post-backup") + if [ "${WEBHOOK_POST_BACKUP_URL}" != "**None**" ]; then + echo "Execute post-backup webhook call to ${WEBHOOK_POST_BACKUP_URL}" + curl --request POST \ + --url "${WEBHOOK_POST_BACKUP_URL}" \ + --header 'Content-Type: application/json' \ + --data '{"status": "error"}' \ + --max-time 10 \ + --retry 5 \ + ${WEBHOOK_EXTRA_ARGS} + fi + ;; +esac +