Add ntfy_token input for authenticated topics
This commit is contained in:
+10
@@ -9,6 +9,10 @@ inputs:
|
||||
ntfy_topic:
|
||||
description: 'ntfy topic'
|
||||
required: true
|
||||
ntfy_token:
|
||||
description: 'ntfy auth token (bearer). Store in CI secret.'
|
||||
default: ''
|
||||
required: false
|
||||
status:
|
||||
description: 'Notification status: success or failure'
|
||||
required: true
|
||||
@@ -24,6 +28,7 @@ runs:
|
||||
env:
|
||||
NTFY_URL: ${{ inputs.ntfy_url }}
|
||||
NTFY_TOPIC: ${{ inputs.ntfy_topic }}
|
||||
NTFY_TOKEN: ${{ inputs.ntfy_token }}
|
||||
MESSAGE: ${{ inputs.message }}
|
||||
run: |
|
||||
if [ "${{ inputs.status }}" = "failure" ]; then
|
||||
@@ -33,9 +38,14 @@ runs:
|
||||
PRIORITY=3
|
||||
TAGS="rocket,white_check_mark,🎉,docker"
|
||||
fi
|
||||
AUTH=()
|
||||
if [ -n "${NTFY_TOKEN}" ]; then
|
||||
AUTH=(-H "Authorization: Bearer ${NTFY_TOKEN}")
|
||||
fi
|
||||
curl -sf \
|
||||
-H "Title: CI Notification" \
|
||||
-H "Priority: ${PRIORITY}" \
|
||||
-H "Tags: ${TAGS}" \
|
||||
"${AUTH[@]}" \
|
||||
-d "${MESSAGE}" \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}"
|
||||
|
||||
Reference in New Issue
Block a user