Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .circleci/rollback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This is a template CircleCI rollback config
# that shows how to use deploy markers to track deployments.
# You can edit this template to add your custom rollback logic.

version: 2.1

jobs:
rollback-component:
docker:
- image: cimg/base:current
environment:
COMPONENT_NAME: << pipeline.deploy.component_name >>
NAMESPACE: << pipeline.deploy.namespace >>
ENVIRONMENT_NAME: << pipeline.deploy.environment_name >>
TARGET_VERSION: << pipeline.deploy.target_version >>
steps:
- checkout
- attach_workspace:
at: .

# This step will create a new deploy with PENDING status
# that will show up in the deploys tab in the UI
- run:
name: Plan release of deploy release smoke test
command: |
circleci run release plan \
--environment-name=${ENVIRONMENT_NAME} \
--namespace=${NAMESPACE} \
--component-name=${COMPONENT_NAME} \
--target-version=${TARGET_VERSION} \
--rollback

- run:
name: Perform rollback
command:
# Add here your custom logic to perform the rollback

# These last two steps update the PENDING deployment marker
# to SUCCESS or FAILED, based on the outcome of the job.
- run:
name: Update planned release to SUCCESS
command: |
circleci run release update \
--status=SUCCESS
when: on_success
- run:
name: Update planned release to FAILED
command: |
circleci run release update \
--status=FAILED \
when: on_fail

# This job handles the cancellation of the rollback deploy marker
# if the rollback job is canceled
cancel-rollback:
docker:
- image: cimg/base:current
steps:
- run:
name: Update planned release to CANCELED
command: |
circleci run release update \
--status=CANCELED

workflows:
rollback:
jobs:
- rollback-component
- cancel-rollback:
requires:
- rollback-component:
- canceled
filters:
branches:
only: main