Skip to content

Commit

Permalink
feat(ci): add send notification step, when update available
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoscode committed Nov 27, 2023
1 parent de2a448 commit 3289407
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/update-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions pipeline/mail_data.tpl.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
14 changes: 14 additions & 0 deletions pipeline/send_mail.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3289407

Please sign in to comment.