mirror of
https://github.com/mag37/dockcheck.git
synced 2026-03-02 23:20:33 +01:00
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:
parent
af202c9d6a
commit
e393a781cf
3 changed files with 26 additions and 9 deletions
|
|
@ -21,3 +21,4 @@
|
||||||
#DRunUp=true # Allow updating images for docker run, wont update the container.
|
#DRunUp=true # Allow updating images for docker run, wont update the container.
|
||||||
#MonoMode=true # Monochrome mode, no printf colour codes and hides progress bar.
|
#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)`
|
#PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)`
|
||||||
|
#PrintMarkdownURL=true # Prints custom releasenote urls as markdown
|
||||||
|
|
|
||||||
14
dockcheck.sh
14
dockcheck.sh
|
|
@ -40,6 +40,7 @@ Help() {
|
||||||
echo "-I Prints custom releasenote urls alongside each container with updates (requires urls.list)."
|
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 "-l Only update if label is set. See readme."
|
||||||
echo "-m Monochrome mode, no printf colour codes and hides progress bar."
|
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 "-n No updates; only checking availability without interaction."
|
||||||
echo "-p Auto-prune dangling images after update."
|
echo "-p Auto-prune dangling images after update."
|
||||||
echo "-r Allow updating images for docker run; won't update the container."
|
echo "-r Allow updating images for docker run; won't update the container."
|
||||||
|
|
@ -66,6 +67,7 @@ ForceRestartStacks=${ForceRestartStacks:=false}
|
||||||
DRunUp=${DRunUp:=false}
|
DRunUp=${DRunUp:=false}
|
||||||
MonoMode=${MonoMode:=false}
|
MonoMode=${MonoMode:=false}
|
||||||
PrintReleaseURL=${PrintReleaseURL:=false}
|
PrintReleaseURL=${PrintReleaseURL:=false}
|
||||||
|
PrintMarkdownURL=${PrintMarkdownURL:=false}
|
||||||
Stopped=${Stopped:=""}
|
Stopped=${Stopped:=""}
|
||||||
CollectorTextFileDirectory=${CollectorTextFileDirectory:-}
|
CollectorTextFileDirectory=${CollectorTextFileDirectory:-}
|
||||||
Exclude=${Exclude:-}
|
Exclude=${Exclude:-}
|
||||||
|
|
@ -86,7 +88,7 @@ c_blue="\033[0;34m"
|
||||||
c_teal="\033[0;36m"
|
c_teal="\033[0;36m"
|
||||||
c_reset="\033[0m"
|
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
|
case "${options}" in
|
||||||
a|y) AutoMode=true ;;
|
a|y) AutoMode=true ;;
|
||||||
c) CollectorTextFileDirectory="${OPTARG}" ;;
|
c) CollectorTextFileDirectory="${OPTARG}" ;;
|
||||||
|
|
@ -97,6 +99,7 @@ while getopts "ayfhiIlmnprsuvc:e:d:t:x:" options; do
|
||||||
I) PrintReleaseURL=true ;;
|
I) PrintReleaseURL=true ;;
|
||||||
l) OnlyLabel=true ;;
|
l) OnlyLabel=true ;;
|
||||||
m) MonoMode=true ;;
|
m) MonoMode=true ;;
|
||||||
|
M) PrintMarkdownURL=true ;;
|
||||||
n) DontUpdate=true; AutoMode=true;;
|
n) DontUpdate=true; AutoMode=true;;
|
||||||
p) AutoPrune=true ;;
|
p) AutoPrune=true ;;
|
||||||
r) DRunUp=true ;;
|
r) DRunUp=true ;;
|
||||||
|
|
@ -229,9 +232,14 @@ releasenotes() {
|
||||||
for update in "${GotUpdates[@]}"; do
|
for update in "${GotUpdates[@]}"; do
|
||||||
found=false
|
found=false
|
||||||
while read -r container url; do
|
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"
|
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
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### 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.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
|
|
@ -12,11 +12,19 @@ trigger_notification() {
|
||||||
GotifyToken="Your Gotify token here"
|
GotifyToken="Your Gotify token here"
|
||||||
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
|
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
|
||||||
|
|
||||||
curl \
|
if [[ "$PrintMarkdownURL" == true ]]; then
|
||||||
-F "title=${MessageTitle}" \
|
ContentType="text/markdown"
|
||||||
-F "message=${MessageBody}" \
|
else
|
||||||
-F "priority=5" \
|
ContentType="text/plain"
|
||||||
-X POST "${GotifyUrl}" 1> /dev/null
|
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() {
|
send_notification() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue