From d81247660d540a5d9302c4f43a5be210a6c8613b Mon Sep 17 00:00:00 2001 From: mahboobeh-binary Date: Thu, 9 Jul 2020 13:08:22 +0800 Subject: [PATCH 1/5] add new release porc --- .circleci/config.yml | 111 ++++++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f5ad8ce9a..b4ec665e5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: k8s: circleci/kubernetes@0.7.0 - s3: circleci/aws-s3@1.0.13 + slack: circleci/slack@3.4.2 commands: git_checkout_from_cache: description: "Git checkout and save cache" @@ -48,7 +48,7 @@ commands: key: bundle-v1-{{ checksum "Gemfile" }} paths: - "modules" - release: + build: description: "Build Jekyll site" steps: - restore_cache: @@ -64,38 +64,33 @@ commands: key: _site-v1-{{ .Revision }} paths: - _site - compress: - description: "Compress" + deploy: + description: "Deploy to static branches" + parameters: + target_branch: + type: string steps: + - checkout + - attach_workspace: + at: _site + - run: + name: Tag build + command: echo "<< parameters.target_branch >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > _site/version - run: - name: "Compress" + name: Install and configure dependencies command: | - pushd _site/ - tar -cvf artifact.tar * - mv artifact.tar ${OLDPWD}/ + curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - + sudo apt install nodejs + sudo npm install -g gh-pages@2.0.1 + git config user.email "ci-build@binary.com" + git config user.name "ci-build" + - add_ssh_keys: + fingerprints: + - "5f:93:6c:f9:55:6b:b7:03:36:5d:59:03:55:9b:45:ed" - run: - name: "Tag commit id as artifact identifer" - command: echo "${CIRCLE_SHA1}" > artifact-info.txt - upload_artifact: - description: "upload build artifact to s3 bucket" - steps: - - s3/copy: - from: artifact.tar - to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/' - aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID - aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY - aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION - arguments: '--metadata "{\"x-amz-artifact-id\": \"${CIRCLE_SHA1}\" }"' - upload_checksum: - description: "upload artifact checksum to s3" - steps: - - s3/copy: - from: artifact-info.txt - to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/' - aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID - aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY - aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION - docker_build: + name: Deploy docs to gh-pages branch + command: gh-pages -d _site --branch << parameters.target_branch >> --message '[skip ci]' + docker_build_push: description: "Build Docker image" steps: - setup_remote_docker @@ -103,9 +98,6 @@ commands: name: Building docker image command: | docker build -t ${DOCKHUB_ORGANISATION}/binary-static-developers:${CIRCLE_SHA1} -t ${DOCKHUB_ORGANISATION}/binary-static-developers:latest . - docker_push: - description: "Push image to docker hub" - steps: - run: name: Pushing Image to docker hub command: | @@ -134,27 +126,58 @@ commands: kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/developers-binary-com developers-binary-com=${DOCKHUB_ORGANISATION}/binary-static-developers:${CIRCLE_SHA1} fi done - + notify_slack: + description: "Notify slack" + steps: + - slack/status: + include_project_field: false + failure_message: "Release failed for Developers with version *$(cat _site/version)*" + success_message: "Release succeeded for Developers with version *$(cat _site/version)*" + webhook: ${SLACK_WEBHOOK} jobs: - release: + build: docker: - image: circleci/ruby:2.6.5 steps: - git_checkout_from_cache - bundle_install - - release - - compress - - upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment - - upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint - - docker_build - - docker_push + - build + release_production: + docker: + - image: circleci/ruby:2.6.5 + steps: + - git_checkout_from_cache + - bundle_install + - build + - deploy: + target_branch: "production" + - notify_slack + release_aws_production: + docker: + - image: circleci/ruby:2.6.5 + steps: + - git_checkout_from_cache + - bundle_install + - build + - docker_build_push - k8s_deploy workflows: + build: + jobs: + - build release: jobs: - - release: + - release_production: + filters: + branches: + ignore: /.*/ + tags: + only: /^production.*/ + - release_aws_production: filters: branches: - only: /^gh-pages$/ - context: binary-frontend-artifact-upload # using context to retrieve shared secret from circle ci + ignore: /.*/ + tags: + only: /^production.*/ + context: binary-frontend-artifact-upload From 7a8d99ea60d025fb03648d7a72ff7d32d8e3cbab Mon Sep 17 00:00:00 2001 From: mahboobeh-binary Date: Thu, 9 Jul 2020 13:14:33 +0800 Subject: [PATCH 2/5] install gh-pages locally --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b4ec665e5..96525748b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -81,7 +81,7 @@ commands: command: | curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt install nodejs - sudo npm install -g gh-pages@2.0.1 + sudo npm install gh-pages@2.0.1 git config user.email "ci-build@binary.com" git config user.name "ci-build" - add_ssh_keys: @@ -89,7 +89,7 @@ commands: - "5f:93:6c:f9:55:6b:b7:03:36:5d:59:03:55:9b:45:ed" - run: name: Deploy docs to gh-pages branch - command: gh-pages -d _site --branch << parameters.target_branch >> --message '[skip ci]' + command: node ./node_modules/gh-pages/bin/gh-pages -d _site --branch << parameters.target_branch >> --message '[skip ci]' docker_build_push: description: "Build Docker image" steps: From 88b08d7d4ed4c9cf400d8fc907759fb9205eb6dc Mon Sep 17 00:00:00 2001 From: mahboobeh-binary Date: Thu, 9 Jul 2020 13:22:51 +0800 Subject: [PATCH 3/5] update user key --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 96525748b..74116e75d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -86,7 +86,7 @@ commands: git config user.name "ci-build" - add_ssh_keys: fingerprints: - - "5f:93:6c:f9:55:6b:b7:03:36:5d:59:03:55:9b:45:ed" + - "01:67:4a:6d:26:9c:70:c4:1a:60:91:88:d9:dd:f0:83" - run: name: Deploy docs to gh-pages branch command: node ./node_modules/gh-pages/bin/gh-pages -d _site --branch << parameters.target_branch >> --message '[skip ci]' From 027b757fed946fc0bb0dbf08b0ad29d108d4451d Mon Sep 17 00:00:00 2001 From: sysadmin-frontend-binary <65759777+sysadmin-frontend-binary@users.noreply.github.com> Date: Wed, 15 Jul 2020 15:23:40 +0800 Subject: [PATCH 4/5] Update .circleci/config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 74116e75d..3636e5807 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -131,7 +131,7 @@ commands: steps: - slack/status: include_project_field: false - failure_message: "Release failed for Developers with version *$(cat _site/version)*" + failure_message: "Release failed for developers.binary.com with version *$(cat _site/version)*" success_message: "Release succeeded for Developers with version *$(cat _site/version)*" webhook: ${SLACK_WEBHOOK} jobs: From f401ee96491fbbc58dc870b02e96e9864c647b25 Mon Sep 17 00:00:00 2001 From: sysadmin-frontend-binary <65759777+sysadmin-frontend-binary@users.noreply.github.com> Date: Wed, 15 Jul 2020 15:23:56 +0800 Subject: [PATCH 5/5] Update .circleci/config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3636e5807..03cd38143 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -132,7 +132,7 @@ commands: - slack/status: include_project_field: false failure_message: "Release failed for developers.binary.com with version *$(cat _site/version)*" - success_message: "Release succeeded for Developers with version *$(cat _site/version)*" + success_message: "Release succeeded for developers.binary.com with version *$(cat _site/version)*" webhook: ${SLACK_WEBHOOK} jobs: build: