diff options
author | EuAndreh <eu@euandre.org> | 2019-06-10 16:01:26 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-06-10 16:01:26 -0300 |
commit | 2292283dca4a2c525d9d93c99a605f926e93585a (patch) | |
tree | 79bf5d59dc009dee51442c02306f1b7397344b6d /scripts/ci/mail.sh | |
parent | Disable $DESTROY_VOLUME operational toggle (diff) | |
download | toph-2292283dca4a2c525d9d93c99a605f926e93585a.tar.gz toph-2292283dca4a2c525d9d93c99a605f926e93585a.tar.xz |
Send logs via email after finishing provision.sh
The email will be send for both sucessfull and failed runs.
Diffstat (limited to 'scripts/ci/mail.sh')
-rwxr-xr-x | scripts/ci/mail.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/ci/mail.sh b/scripts/ci/mail.sh new file mode 100755 index 0000000..d15c5db --- /dev/null +++ b/scripts/ci/mail.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" +cd ../../ + +VPS_COMMIT_SHA="${1:-}" +[[ -z "${VPS_COMMIT_SHA}" ]] && { + echo 'Error: missing $VPS_COMMIT_SHA positional argument.' + exit 2 +} + +SUBJECT="VPS CI run #${JOB_ID} logs" +ATTACHMENT_PATH='logs.txt' +BODY=$(cat <<EOF +CI run for commit ${VPS_COMMIT_SHA}. +See failed run: +https://builds.sr.ht/~euandreh/job/${JOB_ID} + +Logs are attached. + +EOF +) + +cat ./logs/*.txt > "${ATTACHMENT_PATH}" + +curl "${MAILGUN_URL}" \ + -s \ + --user "${MAILGUN_USER}" \ + -F from="${MAILGUN_FROM}" \ + -F to="${MAILGUN_TO}" \ + -F subject="${SUBJECT}" \ + -F text="${BODY}" \ + -F attachment="@${ATTACHMENT_PATH}" |