Skip to content

Commit

Permalink
Update Travis CI to add webhooks and remove cache
Browse files Browse the repository at this point in the history
 ## Why is the change being made?

This change is made because webhooks from GitHub to Discord was annoying
with pushes/pull requests/etc and was not necessary. The necessary
update to developers is the build status of the `master` branch.

This change also addresses the fact that a build has failed to succeed
due to an invalid cache.

 ## What has changed to address the problem?

This change will add a script that will run another script that sends a
webhook of the build. The webhook URL has to be set up in Discord, and
made an environmental variable in Travis CI to work.

 ## How was this change tested?

This change will be tested by making the `webhook` branch emit to
Discord and see if it goes through successfully. Then the branch will be
changed to `master`.

Also, the cache was removed from `.travis.yml`.

 ## Related documents, URLs, commits

https://github.com/DiscordHooks/travis-ci-discord-webhook#guide
  • Loading branch information
Luis729 committed Mar 1, 2020
1 parent 8ef123c commit 02201a8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ language: node_js
node_js:
- lts/*

# Cache node_modules after testing
cache: npm

# Scripts to run to test application
script:
- npm test

# Run coverage after tests pass
after_success: npm run coverage
# Scripts to run after build success/failure
after_success:
- npm run coverage
- ./script/webhook.sh success
after_failure:
- ./script/webhook.sh failure
16 changes: 16 additions & 0 deletions script/webhook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if [ -z $1 ]; then
echo "ERROR: Expecting an argument (success/failure) but got none"
exit 1
fi

if [[ $TRAVIS_BRANCH != 'webhook' ]]; then
echo "INFO: Not the master branch, will not send webhook"
exit 0
fi

echo "INFO: On master branch, sending webhook"
wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
chmod +x send.sh
./send.sh $1 $WEBHOOK_URL

0 comments on commit 02201a8

Please sign in to comment.