Refactor notifications and add helper functions (#182)

* Refactor notifications and add helper functions

* Add helper functions to simplify sourcing files and executing functions if they exist

* Create notify_v2.sh wrapper script

* Simplify and consolidate notification logic within notify_v2.sh

* Support notification management via environment variables

* Move secrets to dockcheck.config

* Fix NOTIFY_CHANNELS default value when not set

* Feedback changes

* Remove leading spaces from MessageBody

* Check for valid notify v2 variables

* Warn on missing configuration and bypass notifications

* Update readme

* Additional feedback fixes

* More comments in default.config with different # depth for comments and settings

* Rename NOTIFY_TOPIC_NAME variable to NTFY_TOPIC_NAME for consistency

* Add TELEGRAM_TOPIC_ID

* Fix AppriseURL variable

* Add an ending newline to all MessageBody statements for consistency

* Remove troubleshooting echo statement

* Prevent attempting to trigger notifications for notification templates if versions are the same

---------

Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
This commit is contained in:
vorezal 2025-05-25 12:26:13 -04:00 committed by GitHub
parent e4b93d113c
commit c63e2441fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 366 additions and 564 deletions

View file

@ -1,9 +1,9 @@
### Custom user variables
# Copy this file to "dockcheck.config" to make it active
# Can be placed in ~/.config/ or alongside dockcheck.sh
#
# Uncomment and set your preferred configuration variables here
# This will not be replaced on updates
## Copy this file to "dockcheck.config" to make it active
## Can be placed in ~/.config/ or alongside dockcheck.sh
##
## Uncomment and set your preferred configuration variables here
## This will not be replaced on updates
#Timeout=10 # Set a timeout (in seconds) per container for registry checkups.
#MaxAsync=10 # Set max asynchronous subprocesses, 1 default, 0 to disable.
@ -23,3 +23,53 @@
#PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)`
#PrintMarkdownURL=true # Prints custom releasenote urls as markdown
#OnlySpecific=true # Only compose up the specific container, not the whole compose. (useful for master-compose structure).
### Notify settings
## All commented values are examples only. Modify as needed.
##
## Uncomment the line below and specify the notification channels you wish to enable in a space separated string
# NOTIFY_CHANNELS="apprise discord DSM generic gotify matrix ntfy-sh pushbullet pushover slack smtp telegram"
#
## Uncomment to not send notifications when dockcheck itself has updates.
# DISABLE_DOCKCHECK_NOTIFICATION=false
## Uncomment to not send notifications when notify scripts themselves have updates.
# DISABLE_NOTIFY_NOTIFICATION=false
#
## Apprise configuration variables. Set APPRISE_PAYLOAD to make a CLI call or set APPRISE_URL to make an API request instead.
# APPRISE_PAYLOAD='mailto://myemail:mypass@gmail.com
# mastodons://{token}@{host}
# pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b
# tgram://{bot_token}/{chat_id}/'
# APPRISE_URL="http://apprise.mydomain.tld:1234/notify/apprise"
#
# DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/<token string>"
#
# DSM_SENDMAILTO="me@mydomain.com"
# DSM_SUBJECTTAG="Email Subject Prefix"
#
# GOTIFY_DOMAIN="https://gotify.domain.tld"
# GOTIFY_TOKEN="token-value"
#
# MATRIX_ACCESS_TOKEN="token-value"
# MATRIX_ROOM_ID="myroom"
# MATRIX_SERVER_URL="https://matrix.yourdomain.tld"
#
# NTFY_TOPIC_NAME="YourUniqueTopicName"
#
# PUSHBULLET_URL="https://api.pushbullet.com/v2/pushes"
# PUSHBULLET_TOKEN="token-value"
#
# PUSHOVER_URL="https://api.pushover.net/1/messages.json"
# PUSHOVER_USER_KEY="userkey"
# PUSHOVER_TOKEN="token-value"
#
# SLACK_CHANNEL_ID=mychannel
# SLACK_ACCESS_TOKEN=xoxb-token-value
#
# SMTP_MAIL_FROM="me@mydomain.tld"
# SMTP_MAIL_TO="you@yourdomain.tld"
# SMTP_SUBJECT_TAG="dockcheck"
#
# TELEGRAM_CHAT_ID="mychatid"
# TELEGRAM_TOKEN="token-value"
# TELEGRAM_TOPIC_ID="0"