Integrate with a collaboration tool
Free Commit sends emails when a build fails, but you might want to send notifications on discord?
#!/bin/bash
curl \
-X POST \
-H "Content-Type: application/json" \
-Ss "$(printenv DISCORD_WEBHOOK_URL)" \
--data "{\"content\": \":no_entry: Build $1 exit with code 143 (Deployment aborted by user)\"}"
#!/bin/bash
handle_exit() {
EXIT_CODE="$?"
echo "Receiving EXIT..."
if [ "$EXIT_CODE" = "0" ]; then
curl \
-X POST \
-H "Content-Type: application/json" \
-Ss "$(printenv DISCORD_WEBHOOK_URL)" \
--data "{\"content\": \":ok: Build $1 exit with code $EXIT_CODE\"}"
else
curl \
-X POST \
-H "Content-Type: application/json" \
-Ss "$(printenv DISCORD_WEBHOOK_URL)" \
--data "{\"content\": \":no_entry: Build $1 exit with code $EXIT_CODE\"}"
fi
exit $EXIT_CODE
}
trap "handle_exit $1" EXIT
version: '1.0'
from: 'romainlavabrefairfair/deploy-react'
steps:
- name: "@cleanup"
script: cleanup.sh gui-dev
- name: '@notify'
script: notify.sh gui-dev
- name: '@init-wrangler'
script: init-wrangler.sh DEV
- name: '@install'
script: npm-ci.sh
- name: '@build-dev1'
script: build.sh dev
- name: '@push-dev1'
script: push.sh dev
And that's it, now send you the exit codes on discord. Do you also want to send the logs?
This time you must use chaining and retrieve the result of your last build
Last updated