The Cookbook: Deployment


In this cookbook, we are going to show you just how flexible you can make the Travis deployment options using bash scripts, stick around and we will show you a great example.

Deployment flexibility

Sometimes your deployment needs more customization than the after_success method allows, if this is the case use a custom bash script. For example, the bash script I wrote below is a script to ignore PR’s:

#!/usr/bin/env sh

echo "Hello from Montana at Travis"

if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
  surge --project ./dist --domain
  echo "This is a PR, not deploying"

In some cases, this will fail – you must remember to set permissions. For example, let’s say this script I just created above I named, I would need to add this in my script section:

chmod +x ./ && ./

In this case, your .travis.yml file would look like this:

  provider: script
  script: chmod +x ./ && ./
    branch: dev

There you go and congratulations you’ve successfully added a bash script in your .travis.yml to instruct your deployment to ignore PR’s, this is just one of the many things you can do with bash when it comes to customizing your deployments.