Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move dev env deployment job to helm repo #1738

Merged
merged 12 commits into from
Sep 18, 2020
57 changes: 0 additions & 57 deletions .circleci/ci_deploy.sh

This file was deleted.

45 changes: 28 additions & 17 deletions .circleci/ci_increase_chart_version.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
#!/bin/sh

"""
This is the script that would send a dispatch event to the helm chart repo to
auto increase chart version.
This is the script that would send a dispatch event to the helm chart repo to auto increase chart version.
You can set the UPDATE_DEV flag to decide whether to update to dev too.

For master, we increase the chart version and update dev together. The app version should be short git sha with length 7.
For release, we increase the chart version only. The app version should be semver. (eg. 1.0.3-pre.0)

Required env vars:
- CIRCLE_TAG
- CHART_NAME
- HELM_CHART_REPO
- CHART_NAME (eg. childchain, watcher, watcher-info)
- APP_VERSION (eg. 3d75118 or 1.0.3-pre.0)
- HELM_CHART_REPO (eg. helm-devlopement)
- UPDATE_DEV (true/false)
- GITHUB_API_TOKEN
"""

set -e
set -x
set -ex

increase_chart_version() {
APP_VERSION="${CIRCLE_TAG#*v}"
[ -z "$CHART_NAME" ] && echo "CHART_NAME should be set" && exit 1
[ -z "$APP_VERSION" ] && echo "APP_VERSION should be set" && exit 1
[ -z "$HELM_CHART_REPO" ] && echo "HELM_CHART_REPO should be set" && exit 1
[ -z "$UPDATE_DEV" ] && echo "HELM_CHART_REPO should be set" && exit 1
[ -z "$GITHUB_API_TOKEN" ] && echo "GITHUB_API_TOKEN should be set" && exit 1

echo "increase chart version for chart: ${CHART_NAME} with APP_VERSION: ${APP_VERSION}"

curl --location --request POST 'https://api.github.com/repos/omgnetwork/'${HELM_CHART_REPO}'/dispatches' \
--header 'Accept: application/vnd.github.v3+json' \
--header 'authorization: token '${GITHUB_API_TOKEN}'' \
--header 'Content-Type: application/json' \
--data-raw '{"event_type": "increase-chart-version", "client_payload": { "chart_name": "'${CHART_NAME}'", "app_version": "'${APP_VERSION}'" }}'
}
echo "increase chart version: chart [${CHART_NAME}], appVersion: [${APP_VERSION}], update_dev: [${UPDATE_DEV}]"

increase_chart_version
curl --location --request POST "https://api.github.com/repos/omgnetwork/${HELM_CHART_REPO}/dispatches" \
--header "Accept: application/vnd.github.v3+json" \
--header "authorization: token ${GITHUB_API_TOKEN}" \
--header "Content-Type: application/json" \
--data-raw " { \
\"event_type\": \"increase-chart-version\", \
\"client_payload\": { \
\"chart_name\": \"${CHART_NAME}\", \
\"app_version\": \"${APP_VERSION}\", \
\"update_dev\": \"${UPDATE_DEV}\" \
} \
}"
55 changes: 28 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -884,47 +884,49 @@ jobs:
path: current_release/
- run: IMAGE_NAME=$WATCHER_INFO_IMAGE_NAME sh .circleci/ci_publish.sh

increase_chart_version_childchain:
increase_chart_version_watcher_master:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: childchain
CHART_NAME: watcher
HELM_CHART_REPO: helm-development
UPDATE_DEV: true
steps:
- checkout
- run: sh .circleci/ci_increase_chart_version.sh
- run: APP_VERSION="$(echo "$CIRCLE_SHA1" | head -c 7)" sh .circleci/ci_increase_chart_version.sh

increase_chart_version_watcher:
increase_chart_version_watcher_info_master:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: watcher
CHART_NAME: watcher-info
HELM_CHART_REPO: helm-development
UPDATE_DEV: true
steps:
- checkout
- run: sh .circleci/ci_increase_chart_version.sh
- run: APP_VERSION="$(echo "$CIRCLE_SHA1" | head -c 7)" sh .circleci/ci_increase_chart_version.sh

increase_chart_version_watcher_info:
increase_chart_version_watcher_release:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: watcher-info
CHART_NAME: watcher
HELM_CHART_REPO: helm-development
UPDATE_DEV: false
steps:
- checkout
- run: sh .circleci/ci_increase_chart_version.sh

deploy_watcher:
executor: deployer
steps:
- checkout
- run: DEPLOY=watcher sh .circleci/ci_deploy.sh
- run: APP_VERSION="${CIRCLE_TAG#*v}" sh .circleci/ci_increase_chart_version.sh

deploy_watcher_info:
executor: deployer
increase_chart_version_watcher_info_release:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: watcher-info
HELM_CHART_REPO: helm-development
UPDATE_DEV: false
steps:
- checkout
- run: DEPLOY=watcher_info sh .circleci/ci_deploy.sh
- run: APP_VERSION="${CIRCLE_TAG#*v}" sh .circleci/ci_increase_chart_version.sh

coveralls_report:
docker:
Expand Down Expand Up @@ -1002,7 +1004,9 @@ workflows:
- test_barebone_release:
filters: *all_branches_and_tags
- notify_services:
Copy link
Contributor Author

@boolafish boolafish Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually shall this be from helm repo instead??? @JBunCE @arthurk

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep i think that would be a better place to do it, just because the increase_chart_version_XXX has been run doesn't mean it's deployed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will have to be separate PR as I don't even know how to do that yet 😛

requires: [deploy_watcher, deploy_watcher_info]
requires:
- increase_chart_version_watcher_master
- increase_chart_version_watcher_info_master
filters:
branches:
only:
Expand Down Expand Up @@ -1091,21 +1095,21 @@ workflows:
audit_deps
]
filters: *master_and_version_branches_and_all_tags
# Release deploy to development in case of master branch.
- deploy_watcher:
# Increase chart version for master, this will end up trigger deployment on dev
- increase_chart_version_watcher_master:
requires: [publish_watcher, publish_watcher_info]
filters:
branches:
only:
- master
- deploy_watcher_info:
- increase_chart_version_watcher_info_master:
requires: [publish_watcher, publish_watcher_info]
filters:
branches:
only:
- master
# Increase chart version for new release
- increase_chart_version_childchain:
- increase_chart_version_watcher_release:
requires: [publish_watcher, publish_watcher_info]
filters: &only_release_tag
branches:
Expand All @@ -1114,9 +1118,6 @@ workflows:
only:
# eg. v1.0.3-pre.0, v1.0.3, ...
- /^v[0-9]+\.[0-9]+\.[0-9]+.*/
- increase_chart_version_watcher:
requires: [publish_watcher, publish_watcher_info]
filters: *only_release_tag
- increase_chart_version_watcher_info:
- increase_chart_version_watcher_info_release:
requires: [publish_watcher, publish_watcher_info]
filters: *only_release_tag