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

chore: move deployment to helm repo with GH api #15

Merged
merged 3 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
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
45 changes: 0 additions & 45 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}\" \
} \
}"
26 changes: 16 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ jobs:
name: Run Child Chain
command: |
set -e
mix deps.get
mix deps.get
make start-child_chain OVERRIDING_START=start_iex OVERRIDING_VARIABLES=./bin/variables_test_barebone
background: true
no_output_timeout: 2400
Expand All @@ -636,21 +636,27 @@ jobs:
- run: make docker-child_chain CHILD_CHAIN_IMAGE_NAME=$CHILD_CHAIN_IMAGE_NAME
- run: IMAGE_NAME=$CHILD_CHAIN_IMAGE_NAME sh .circleci/ci_publish.sh

increase_chart_version_childchain:
increase_chart_version_master:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: childchain
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

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

notify_services:
executor: builder_pg
Expand Down Expand Up @@ -718,7 +724,7 @@ workflows:
- test_barebone_release:
filters: *all_branches_and_tags
- notify_services:
requires: [deploy_child_chain]
requires: [increase_chart_version_master]
filters:
branches:
only:
Expand Down Expand Up @@ -778,15 +784,15 @@ workflows:
tags:
only:
- /.+/
# Release deploy to development in case of master branch.
- deploy_child_chain:
# Increase chart version for master, this will end up trigger deployment on dev
- increase_chart_version_master:
requires: [publish_child_chain]
filters:
branches:
only:
- master
# Increase chart version for new release
- increase_chart_version_childchain:
- increase_chart_version_release:
requires: [publish_child_chain]
filters: &only_release_tag
branches:
Expand Down