action-notify-ntfy/entrypoint.sh

32 lines
1.1 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
2023-03-27 22:11:09 +00:00
echo "Notifying job status: $1"
2023-03-27 21:25:16 +00:00
#GITHUB_RUN_NUMBER
# Job status: success/failure/cancelled
2023-03-27 22:11:09 +00:00
if [ "$1" = "success" ]; then
2023-03-27 22:13:38 +00:00
curl -s -u "${INPUT_USER}:${INPUT_PASSWORD}" \
2023-03-27 22:11:09 +00:00
-H "Title: Job Succeeded. ${GITHUB_REPOSITORY}/${GITHUB_REF}" \
-H "Tags: +1" \
-d "Job succeeded. See $GITHUB_SERVER_URL/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_NUMBER} for details" \
"${INPUT_HOST}${INPUT_TOPIC}"
elif [ "$1" = "failure" ]; then
2023-03-27 22:13:38 +00:00
curl -s -u "${INPUT_USER}:${INPUT_PASSWORD}" \
2023-03-27 22:11:09 +00:00
-H "Title: Job FAILED. ${GITHUB_REPOSITORY}/${GITHUB_REF}" \
-H "Priority: high" \
-H "Tags: warning" \
-d "Job failed. See $GITHUB_SERVER_URL/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_NUMBER} for details" \
"${INPUT_HOST}${INPUT_TOPIC}"
elif [ "$1" = "cancelled" ]; then
2023-03-27 22:13:38 +00:00
curl -s -u "${INPUT_USER}:${INPUT_PASSWORD}" \
2023-03-27 22:11:09 +00:00
-H "Title: Job cancelled. ${GITHUB_REPOSITORY}/${GITHUB_REF}" \
-H "Priority: low" \
-H "Tags: x" \
-d "Job cancelled. See $GITHUB_SERVER_URL/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_NUMBER} for details" \
"${INPUT_HOST}${INPUT_TOPIC}"
else
echo "Unknown job status $1"
exit 1
fi