pokeemerald/.travis/calcrom/webhook.sh

17 lines
646 B
Bash
Raw Normal View History

2018-06-16 18:39:54 +02:00
#!/bin/bash -ex
# Only run this script if it's the master branch build.
if [[ "$TRAVIS_BRANCH" != "master" || "$TRAVIS_PULL_REQUEST" != "false" ]]; then
exit 0
fi
build_name=$1
map_file=$build_name.map
if [ ! -f $map_file ]; then
echo "$map_file does not exist!"
exit 1
fi
output=$(perl $(dirname "$0")/calcrom.pl $build_name.map | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
curl -d "{\"username\": \"OK\", \"avatar_url\": \"https://i.imgur.com/38BQHdd.png\", \"content\":\"\`\`\`$build_name progress:\\n$output\`\`\`\"}" -H "Content-Type: application/json" -X POST https://discordapp.com/api/webhooks/340931107060973570/$DISCORD_WEBHOOK_KEY