Post failures to gitea-releases too, as errors is the generic fallback topic
This commit is contained in:
1 parent
56859d4d1b
commit
de3c6a25a1
2 files changed
+11
-19
No files matched your search
@@ -1,8 +1,8 @@
|
||||
# ci-notify
|
||||
|
||||
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
|
||||
everything passed on `master` posts to `gitea-releases`. Each notification
|
||||
other job: a failed job posts to `gitea-releases` at priority 5, and a run
|
||||
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
|
||||
stays quiet.
|
||||
|
||||
@@ -19,4 +19,4 @@ stays quiet.
|
||||
```
|
||||
|
||||
`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
@@ -14,16 +14,10 @@ inputs:
|
||||
description: ntfy server URL
|
||||
default: https://ntfy.zlymeda.dynu.net
|
||||
ntfy_topic:
|
||||
description: Topic for successes
|
||||
description: ntfy topic
|
||||
default: gitea-releases
|
||||
ntfy_token:
|
||||
description: Token for successes (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
|
||||
description: ntfy token (secrets.NTFY_TOKEN)
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
@@ -37,8 +31,6 @@ runs:
|
||||
NTFY_URL: ${{ inputs.ntfy_url }}
|
||||
NTFY_TOPIC: ${{ inputs.ntfy_topic }}
|
||||
NTFY_TOKEN: ${{ inputs.ntfy_token }}
|
||||
NTFY_FAILURE_TOPIC: ${{ inputs.ntfy_failure_topic }}
|
||||
NTFY_FAILURE_TOKEN: ${{ inputs.ntfy_failure_token }}
|
||||
REPO: ${{ github.repository }}
|
||||
BRANCH: ${{ github.ref_name }}
|
||||
SHA: ${{ github.sha }}
|
||||
@@ -55,19 +47,19 @@ runs:
|
||||
cancelled=$(awk '$2 == "cancelled" { print $1 }' <<<"$results")
|
||||
passed=$(awk '$2 == "success" { printf "%s%s", sep, $1; sep = ", " }' <<<"$results")
|
||||
|
||||
send() { # topic token priority tags message
|
||||
send() { # priority tags message
|
||||
auth=()
|
||||
[ -n "$2" ] && auth=(-H "Authorization: Bearer $2")
|
||||
curl -sSf -H "Title: $REPO ($BRANCH)" -H "Priority: $3" -H "Tags: $4" -H "Click: $RUN_URL" \
|
||||
"${auth[@]}" -d "$5" "$NTFY_URL/$1" >/dev/null
|
||||
[ -n "$NTFY_TOKEN" ] && auth=(-H "Authorization: Bearer $NTFY_TOKEN")
|
||||
curl -sSf -H "Title: $REPO ($BRANCH)" -H "Priority: $1" -H "Tags: $2" -H "Click: $RUN_URL" \
|
||||
"${auth[@]}" -d "$3" "$NTFY_URL/$NTFY_TOPIC" >/dev/null
|
||||
}
|
||||
|
||||
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
|
||||
echo "cancelled, nothing to announce"
|
||||
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
|
||||
echo "$BRANCH is not announced on success"
|
||||
fi
|
||||
Reference in new issue
Block a user