Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
description: > | |
Deploy via helm, using chart found in the helm_deploy dir of the repo. | |
Optionally send a slack notification. | |
executor: | |
name: default_small | |
tag: "3.10" | |
parameters: | |
env: | |
type: string | |
default: dev | |
release_name: | |
type: string | |
default: PROJECT_NAME | |
chart_name: | |
type: string | |
default: PROJECT_NAME | |
chart_version: | |
type: string | |
default: latest | |
helm_repo: | |
type: string | |
default: local | |
description: For using non local helm chart set to URL of helm repo | |
helm_dir: | |
type: string | |
default: helm_deploy | |
slack_notification: | |
type: boolean | |
default: false | |
description: When true, notifies a Slack channel after every deployment done with this job. | |
slack_channel_name: | |
type: string | |
default: "dps-releases" | |
description: Slack channel to use for deployment notifications. | |
helm_additional_args: | |
type: string | |
default: "" | |
show_changelog: | |
type: boolean | |
default: true | |
description: When true, displays what is new since the previous deployment in the job, and in Slack, if applicable | |
changelog_git_paths: | |
type: string | |
default: "" | |
description: When set it will limit the file changes shown in the changelog to the specified paths only. This is useful for multi-project builds where otherwise it will show all changes from all projects. | |
k8s_deployment_name: | |
type: string | |
default: PROJECT_NAME | |
description: The Deployment resource's name in Kubernetes to interrogate for the previous deployment's version | |
jira_update: | |
type: boolean | |
default: false | |
description: When true, updates any referenced Jira tickets with deployment information. Note that Jira integration must be enabled in your CircleCI project settings. | |
jira_env_type: | |
type: enum | |
default: development | |
description: Environment type to use when updating Jira | |
enum: | |
- production | |
- staging | |
- testing | |
- development | |
- unmapped | |
helm_timeout: | |
type: string | |
default: 5m | |
pipeline_id: | |
type: string | |
default: "" | |
description: Required if jira_update is set (otherwise the Notify Jira job will pass but do nothing), passed in as << pipeline.id >> | |
pipeline_number: | |
type: integer | |
default: 0 | |
description: Required if jira_update is set, passed in as << pipeline.number >> | |
steps: | |
- checkout | |
- k8s_setup | |
- install_helm | |
- install_aws_cli | |
- mem/recall: | |
env_var: APP_VERSION | |
- when: | |
condition: <<parameters.show_changelog>> | |
steps: | |
- run: | |
name: Show changes about to be released on << parameters.env >> | |
environment: | |
K8S_DEPLOYMENT_NAME: << parameters.k8s_deployment_name >> | |
CHANGELOG_GIT_PATHS: << parameters.changelog_git_paths >> | |
command: <<include(scripts/version_history.sh)>> | |
- run: | |
name: Store deployment changelog | |
command: | | |
echo 'export DEPLOYMENT_CHANGELOG=$(<.deployment_changelog)' >> $BASH_ENV | |
- mem/recall: | |
env_var: APP_VERSION | |
- run: | |
name: Deploy to << parameters.env >> | |
working_directory: << parameters.helm_dir >> | |
environment: | |
RELEASE_NAME: << parameters.release_name >> | |
CHART_NAME: << parameters.chart_name >> | |
CHART_VERSION: << parameters.chart_version >> | |
HELM_REPO: << parameters.helm_repo >> | |
ENV_NAME: << parameters.env >> | |
HELM_ADDITIONAL_ARGS: << parameters.helm_additional_args >> | |
HELM_TIMEOUT: << parameters.helm_timeout >> | |
command: <<include(scripts/deploy_env.sh)>> | |
- when: | |
condition: <<parameters.slack_notification>> | |
steps: | |
- run: | |
name: Slack channels to notify | |
command: | | |
# For prod releases only always notify central dps-releases channel in addition to custom team channels. | |
if [[ "<< parameters.env >>" == "prod" || "<< parameters.env >>" == "production" ]]; then | |
# By default send to channel ID CVA3MKDTR = #dps-releases | |
if [[ "<< parameters.slack_channel_name >>" == "CVA3MKDTR" || "<< parameters.slack_channel_name >>" == "dps-releases" ]]; then | |
NOTIFY_SLACK_CHANNELS="CVA3MKDTR" | |
else | |
# Also send to custom team channel | |
NOTIFY_SLACK_CHANNELS="CVA3MKDTR,<< parameters.slack_channel_name >>" | |
fi | |
else | |
# non prod envs, send to custom team channel. | |
NOTIFY_SLACK_CHANNELS="<< parameters.slack_channel_name >>" | |
fi | |
echo "export NOTIFY_SLACK_CHANNELS=$NOTIFY_SLACK_CHANNELS" >> $BASH_ENV | |
- slack/notify: | |
event: always | |
channel: ${NOTIFY_SLACK_CHANNELS} | |
custom: | | |
{ | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*${RELEASE_NAME}* version `${APP_VERSION}` deploy to *<< parameters.env >>*" | |
}, | |
"accessory": { | |
"type": "button", | |
"text": { | |
"type": "plain_text", | |
"text": "View job" | |
}, | |
"url": "${CIRCLE_BUILD_URL}" | |
} | |
}, | |
{ | |
"type": "context", | |
"elements": [ | |
{ | |
"type": "mrkdwn", | |
"text": ":circleci-${CCI_STATUS}: Deploy ${CCI_STATUS}" | |
}, | |
{ | |
"type": "plain_text", | |
"text": "\n${DEPLOYMENT_CHANGELOG}" | |
} | |
] | |
} | |
] | |
} | |
- when: | |
condition: << parameters.jira_update >> | |
steps: | |
- jira/notify: | |
job_type: deployment | |
environment: << parameters.env >> | |
environment_type: << parameters.jira_env_type >> | |
pipeline_id: << parameters.pipeline_id >> | |
pipeline_number: << parameters.pipeline_number >> |