Build and deploy to development / staging / production

Okay, so I’m learning travis after years using the glorified job runner that is Jenkins. Basically, my intent is to build+test on every commit to anything, deploy to dev/test for main, then use tagging for releases that are deployed to staging and, ultimately, production.

Clearly optimizing my build file is my first step. What’s the right top level structure to deploy to multiple providers on merge to main? Seems like I need to remove the build stage itself, but wondering if you can advise on an optimal structure for the file.

Thanks for your help!

If you only build one project configuration, a single job would be enough, with one or more deployment clauses, with different deployment conditions:

  - <to dev env>
      branch: main
  - <to staging>
    on: <...>
  - <to production>
    on: <...>

See Can we deploy into different environments from the same branch? - #2 by native-api for options for the last two conditions.

1 Like