diff --git a/README.md b/README.md index dd53de1..2a2ea73 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,8 @@ You can configure the most behaviors of *Gantry* via environment variables. | GANTRY_CLEANUP_IMAGES_OPTIONS | | [Options](https://docs.docker.com/engine/reference/commandline/service_create/#options) added to the `docker service create` command to create a global job for images removal. You can use this to add a label to the service or the containers. | | GANTRY_NOTIFICATION_APPRISE_URL | | Enable notifications on service update with [apprise](https://github.com/caronc/apprise-api). This must point to the notification endpoint (e.g. `http://apprise:8000/notify`) | | GANTRY_NOTIFICATION_TITLE | | Add an additional message to the notification title. | +| GANTRY_NOTIFICATION_CONDITION | all | Specifies the conditions under which notifications are sent. + Set to `all` to send notifications every run. Set to `changed-only` to send notifications only when there is a change or an error. | ## Authentication diff --git a/src/lib-gantry.sh b/src/lib-gantry.sh index 5f35f5a..31cf7fc 100755 --- a/src/lib-gantry.sh +++ b/src/lib-gantry.sh @@ -400,7 +400,17 @@ _report_services() { local TITLE BODY TITLE="[${STACK}] ${NUM_UPDATED} services updated ${NUM_FAILED} failed${ERROR_STRING}" BODY=$(echo -e "${UPDATED_MSG}\n${FAILED_MSG}\n${ERROR_MSG}") - _send_notification "${TYPE}" "${TITLE}" "${BODY}" + + case "${GANTRY_NOTIFICATION_CONDITION:-all}" in + changed-only) + if [ "${NUM_UPDATED}" -gt 0 ] || [ "${NUM_TOTAL_ERRORS}" -gt 0 ]; then + _send_notification "${TYPE}" "${TITLE}" "${BODY}" + fi + ;; + all|*) + _send_notification "${TYPE}" "${TITLE}" "${BODY}" + ;; + esac } _in_list() {