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