I work with Node & I have two different environments that I want to deploy to: staging & production.
The workflow should be:
Every push to master -> build -> deploy to staging
Every v* tag -> build -> deploy to production
My build job is just running tests.
My existing deploy script is designed to leverage all the existing node tooling, so I would want to run it with the exact same environment & dependencies as I ran it with my tests.
Ultimately, after a master build I want to run the command
yarn deploy staging and after a staging build I want to run
yarn deploy production.
My build task looks like this:
build: working_directory: ~/TryGhost/my-repo docker: - image: circleci/node:6.13.0 steps: - checkout - yarn - yarn test
My workflows need to look something like:
workflows: version: 2 staging: jobs: - deploy: requires: build filters: branches: only: master production: jobs: - deploy: requires: build filters: tags: only: /^v.*/
However, the only thing I can see to do is to create 2x deploy jobs which are identical to the build job but swap
yarn test for
yarn deploy x.
That means having 3x duplication of the docker setup, checkout, dependency install, etc.
Am I missing something?