Automatically deploy branches that match name pattern

Hi @fool, sorry for the late reply I’ve been away on holiday and just spent the last day experimenting with the setup. That’s really cool that you can do that in the netlify.toml file. I’ve now got my setup for Middleman working like this:

[context.deploy-preview]
  command = '''
  if echo $BRANCH | grep "^cms" ;
    then NO_CONTRACTS=true RUBYOPT=-W0 middleman build $CMS_PR_BUILD_OPTIONS
  else
    yarn test && RUBYOPT=-W0 parallel_rspec -n 2 spec && NO_CONTRACTS=true RUBYOPT=-W0 middleman build --verbose
  fi
  '''

[[plugins]]
  package = "netlify-plugin-chromium"

So on a deploy preview, if the branch begins with cms then I can run just the Middleman build command, otherwise it’s running all of the specs first and then the build. I’ve also got CMS_PR_BUILD_OPTIONS empty by default but if a build from the CMS fails then I can quickly add --verbose to the environment variables in the Netlify UI and retry the deploy to get a more verbose output from the build. This should be pretty rare so turning it on only when needed saves the additional time of the verbose build.

2 Likes