Was using a feature of the 1.0 “deployment” section to run a different command depending on the branch name. In 2.0, I see that we use workflows to only run the build for a specific branch, but I’m struggling to find examples where certain commands are run inside a workflow. I’m likely just struggling to understand the docs and example configs.
For example, let’s say I have two branches, foo & bar. After the build has completed, I want to run the command “rake foo” for the “foo” branch and “rake bar” for the “bar” branch.
I’ve been able to have specific workflows run depending on the branch, but it seems like it doesn’t keep the state from the main build workflow so there’s a ton of config duplication.
I haven’t had a chance to test it yet, but I read on another thread that something like this should work:
- type: deploy
name: "Deploy to staging"
command: |
if [ "${CIRCLE_BRANCH}" == "staging" ];
now ./_site -t ${NOW_TOKEN}
now -t ${NOW_TOKEN} alias thing-staging
fi
- type: deploy
name: "Deploy to production"
command: |
if [ "${CIRCLE_BRANCH}" == "master" ];
now ./_site -t ${NOW_TOKEN}
now -t ${NOW_TOKEN} alias thing
fi
Just a thought, but it you can use the attach_workspace to pass anything from the build stage to subsequent deploy stages in the workflow. Then using the filter feature in the workflow you can distinguish staging, production, etc. And with less task specific logic in the jobs, you are getting some better level or repeatability/visibility into how each job behaves over time.