diff --git a/.github/workflows/update-check.yml b/.github/workflows/update-check.yml index 324b249..8ea035f 100644 --- a/.github/workflows/update-check.yml +++ b/.github/workflows/update-check.yml @@ -25,4 +25,9 @@ jobs: - name: Check for updates run: | - hcuc --docker-hub-repo gotify/server --debug + hcuc --docker-hub-repo gotify/server --fail-on-update --debug + + - name: Send notification + if: failure() + run: | + ./pipeline/send_mail.sh diff --git a/pipeline/mail_data.tpl.json b/pipeline/mail_data.tpl.json new file mode 100644 index 0000000..d94b06a --- /dev/null +++ b/pipeline/mail_data.tpl.json @@ -0,0 +1,21 @@ +{ + "Messages":[ + { + "From": { + "Email": "$MAILJET_FROM_MAIL" + }, + "To": [ + { + "Email": "$MAILJET_TO_MAIL" + } + ], + "TemplateID": 4829964, + "TemplateLanguage": true, + "Subject": "$MAILJET_SUBJECT", + "Variables": { + "project_name": "$GITHUB_REPOSITORY", + "project_url": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + } + } + ] +} diff --git a/pipeline/send_mail.sh b/pipeline/send_mail.sh new file mode 100755 index 0000000..1eb2ee6 --- /dev/null +++ b/pipeline/send_mail.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +cat pipeline/mail_data.tpl.json | envsubst > mail_data.json + +curl -s \ + -X POST \ + --user "$MAILJET_KEY:$MAILJET_SECRET" \ + https://api.mailjet.com/v3.1/send \ + -H 'Content-Type: application/json' \ + -d '@./mail_data.json' + +rm mail_data.json