Post failures to gitea-releases too, as errors is the generic fallback topic

This commit is contained in:
meda committed 2026-10-28 09:41:23 +01:00
1 parent 56859d4d1b
commit de3c6a25a1
2 files changed
+11 -19

No files matched your search

+3 -3
View File
@@ -1,8 +1,8 @@
# ci-notify # ci-notify
One ntfy notification per workflow run. Add it as the last job, needing every One ntfy notification per workflow run. Add it as the last job, needing every
other job: a failed job posts to `errors` (priority 5), and a run where other job: a failed job posts to `gitea-releases` at priority 5, and a run
everything passed on `master` posts to `gitea-releases`. Each notification where everything passed on `master` posts there at priority 3. Each notification
links to the run. Other branches only report failures, so a feature branch push links to the run. Other branches only report failures, so a feature branch push
stays quiet. stays quiet.
@@ -19,4 +19,4 @@ stays quiet.
``` ```
`success_branches` widens what is announced (e.g. `master develop`), and the `success_branches` widens what is announced (e.g. `master develop`), and the
topics and tokens can be overridden. topic and token can be overridden.
+8 -16
View File
@@ -14,16 +14,10 @@ inputs:
description: ntfy server URL description: ntfy server URL
default: https://ntfy.zlymeda.dynu.net default: https://ntfy.zlymeda.dynu.net
ntfy_topic: ntfy_topic:
description: Topic for successes description: ntfy topic
default: gitea-releases default: gitea-releases
ntfy_token: ntfy_token:
description: Token for successes (secrets.NTFY_TOKEN) description: ntfy token (secrets.NTFY_TOKEN)
default: ''
ntfy_failure_topic:
description: Topic for failures
default: errors
ntfy_failure_token:
description: Token for failures; the errors topic takes anonymous posts
default: '' default: ''
runs: runs:
@@ -37,8 +31,6 @@ runs:
NTFY_URL: ${{ inputs.ntfy_url }} NTFY_URL: ${{ inputs.ntfy_url }}
NTFY_TOPIC: ${{ inputs.ntfy_topic }} NTFY_TOPIC: ${{ inputs.ntfy_topic }}
NTFY_TOKEN: ${{ inputs.ntfy_token }} NTFY_TOKEN: ${{ inputs.ntfy_token }}
NTFY_FAILURE_TOPIC: ${{ inputs.ntfy_failure_topic }}
NTFY_FAILURE_TOKEN: ${{ inputs.ntfy_failure_token }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
BRANCH: ${{ github.ref_name }} BRANCH: ${{ github.ref_name }}
SHA: ${{ github.sha }} SHA: ${{ github.sha }}
@@ -55,19 +47,19 @@ runs:
cancelled=$(awk '$2 == "cancelled" { print $1 }' <<<"$results") cancelled=$(awk '$2 == "cancelled" { print $1 }' <<<"$results")
passed=$(awk '$2 == "success" { printf "%s%s", sep, $1; sep = ", " }' <<<"$results") passed=$(awk '$2 == "success" { printf "%s%s", sep, $1; sep = ", " }' <<<"$results")
send() { # topic token priority tags message send() { # priority tags message
auth=() auth=()
[ -n "$2" ] && auth=(-H "Authorization: Bearer $2") [ -n "$NTFY_TOKEN" ] && auth=(-H "Authorization: Bearer $NTFY_TOKEN")
curl -sSf -H "Title: $REPO ($BRANCH)" -H "Priority: $3" -H "Tags: $4" -H "Click: $RUN_URL" \ curl -sSf -H "Title: $REPO ($BRANCH)" -H "Priority: $1" -H "Tags: $2" -H "Click: $RUN_URL" \
"${auth[@]}" -d "$5" "$NTFY_URL/$1" >/dev/null "${auth[@]}" -d "$3" "$NTFY_URL/$NTFY_TOPIC" >/dev/null
} }
if [ -n "$failed" ]; then if [ -n "$failed" ]; then
send "$NTFY_FAILURE_TOPIC" "$NTFY_FAILURE_TOKEN" 5 "rotating_light,warning" "Failed: $failed (${SHA:0:7})" send 5 "rotating_light,warning" "Failed: $failed (${SHA:0:7})"
elif [ -n "$cancelled" ]; then elif [ -n "$cancelled" ]; then
echo "cancelled, nothing to announce" echo "cancelled, nothing to announce"
elif [ -n "$passed" ] && [[ " $SUCCESS_BRANCHES " == *" $BRANCH "* ]]; then elif [ -n "$passed" ] && [[ " $SUCCESS_BRANCHES " == *" $BRANCH "* ]]; then
send "$NTFY_TOPIC" "$NTFY_TOKEN" 3 "rocket,white_check_mark" "Passed: $passed (${SHA:0:7})" send 3 "rocket,white_check_mark" "Passed: $passed (${SHA:0:7})"
else else
echo "$BRANCH is not announced on success" echo "$BRANCH is not announced on success"
fi fi