Add option to format releasenotes as markdown (#170)

* feat: allow markdown formatting for gotify
* feat: add option to cli args
* fix: use markdown for missing urls
* fix: do not print curl
* fix: add empty line
* bump template version

---------

Co-authored-by: Tobias Diekel <td@diekel.eu>
This commit is contained in:
Tobias Diekel 2025-05-02 20:08:04 +02:00 committed by GitHub
parent af202c9d6a
commit e393a781cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 9 deletions

View file

@ -21,3 +21,4 @@
#DRunUp=true # Allow updating images for docker run, wont update the container.
#MonoMode=true # Monochrome mode, no printf colour codes and hides progress bar.
#PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)`
#PrintMarkdownURL=true # Prints custom releasenote urls as markdown

View file

@ -40,6 +40,7 @@ Help() {
echo "-I Prints custom releasenote urls alongside each container with updates (requires urls.list)."
echo "-l Only update if label is set. See readme."
echo "-m Monochrome mode, no printf colour codes and hides progress bar."
echo "-M Prints custom releasenote urls as markdown."
echo "-n No updates; only checking availability without interaction."
echo "-p Auto-prune dangling images after update."
echo "-r Allow updating images for docker run; won't update the container."
@ -66,6 +67,7 @@ ForceRestartStacks=${ForceRestartStacks:=false}
DRunUp=${DRunUp:=false}
MonoMode=${MonoMode:=false}
PrintReleaseURL=${PrintReleaseURL:=false}
PrintMarkdownURL=${PrintMarkdownURL:=false}
Stopped=${Stopped:=""}
CollectorTextFileDirectory=${CollectorTextFileDirectory:-}
Exclude=${Exclude:-}
@ -86,7 +88,7 @@ c_blue="\033[0;34m"
c_teal="\033[0;36m"
c_reset="\033[0m"
while getopts "ayfhiIlmnprsuvc:e:d:t:x:" options; do
while getopts "ayfhiIlmMnprsuvc:e:d:t:x:" options; do
case "${options}" in
a|y) AutoMode=true ;;
c) CollectorTextFileDirectory="${OPTARG}" ;;
@ -97,6 +99,7 @@ while getopts "ayfhiIlmnprsuvc:e:d:t:x:" options; do
I) PrintReleaseURL=true ;;
l) OnlyLabel=true ;;
m) MonoMode=true ;;
M) PrintMarkdownURL=true ;;
n) DontUpdate=true; AutoMode=true;;
p) AutoPrune=true ;;
r) DRunUp=true ;;
@ -229,9 +232,14 @@ releasenotes() {
for update in "${GotUpdates[@]}"; do
found=false
while read -r container url; do
if [[ "$update" == "$container" ]]; then Updates+=("$update -> $url"); found=true; fi
if [[ "$update" == "$container" ]] && [[ "$PrintMarkdownURL" == true ]]; then Updates+=("- [$update]($url)"); found=true;
elif [[ "$update" == "$container" ]]; then Updates+=("$update -> $url"); found=true;
fi
done < "${ScriptWorkDir}/urls.list"
if [[ "$found" == false ]]; then Updates+=("$update -> url missing"); else continue; fi
if [[ "$found" == false ]] && [[ "$PrintMarkdownURL" == true ]]; then Updates+=("- $update -> url missing");
elif [[ "$found" == false ]]; then Updates+=("$update -> url missing");
else continue;
fi
done
}

View file

@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
NOTIFY_GOTIFY_VERSION="v0.1"
NOTIFY_GOTIFY_VERSION="v0.2"
#
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up.
@ -12,11 +12,19 @@ trigger_notification() {
GotifyToken="Your Gotify token here"
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
curl \
-F "title=${MessageTitle}" \
-F "message=${MessageBody}" \
-F "priority=5" \
-X POST "${GotifyUrl}" 1> /dev/null
if [[ "$PrintMarkdownURL" == true ]]; then
ContentType="text/markdown"
else
ContentType="text/plain"
fi
JsonData=$( jq -n \
--arg body "$MessageBody" \
--arg title "$MessageTitle" \
--arg type "$ContentType" \
'{message: $body, title: $title, priority: 5, extras: {"client::display": {"contentType": $type}}}' )
curl -s -S --data "${JsonData}" -H 'Content-Type: application/json' -X POST "${GotifyUrl}" 1> /dev/null
}
send_notification() {