The way we deploy from staging to production is by doing a
--ff-only merge. Because we have CircleCI update our git-dumped database schema after each PR is merged, the last commit in staging should always be ignored by CI. That can be easily done by adding “[ci skip]” to the commit name, but the problem is then that the
--ff-only merge from staging to production won’t trigger a CI deployment. How do I ensure that some commits are skipped by certain stages?
Instead, we tried rolling our own equivalent “[skip-ci-staging]”, which should only skip the CI for the staging branch. Seeing as we already have separate workflows for staging/production, it’s easy to only add a condition to check for this flag to the workflow for staging. You can see the code below:
ci_skip_check: docker: - image: circleci/python:3.6.1 working_directory: ~/repo steps: - checkout # Skip auto-commit builds produced by our CI, but only for staging # (with a standard "[ci skip]", it won't trigger CI on fastforward merge) - run: command: | COMMIT_MSG=$(git log --format=oneline -n 1 $CIRCLE_SHA1) if [[ $COMMIT_MSG == *"[skip-ci-staging]"* ]]; then echo "[skip-ci-staging] detected. Stopping." circleci step halt fi
Our workflow consists of many different jobs and this job is put ahead of all of them with the others as requiring this one. It correctly detects the job and halts, but only halts the current job and not the entire workflow. We could make it raise an error instead to stop the workflow, but then that would trigger an email alert etc. every single time. We can’t have that. What’s the equivalent command to
circleci step halt that makes the entire workflow stop?