From 786e6d7d6e39ee6e6111182b7b4e19a48551066a Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 16:46:31 -0700 Subject: [PATCH 01/60] comment out unused features --- deploy/releases/app.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index 9564685..bba6fd1 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -23,8 +23,8 @@ releases: repository: '{{ env "IMAGE_NAME" | default "cloudposse/example-app" }}' tag: '{{ env "IMAGE_TAG" | default "0.1.0" }}' pullPolicy: Always - pullSecrets: - - "{{ requiredEnv "RELEASE_NAME" }}-pull-secret-dockercfg " + #pullSecrets: + # - "{{ requiredEnv "RELEASE_NAME" }}-pull-secret-dockercfg " replicaCount: 5 # Deployment configuration deployment: @@ -68,7 +68,7 @@ releases: ### Required: APP_HOST; '{{ env "APP_HOST" }}': / tls: - ### Optional: ATLANTIS_TLS_SECRET_NAME; + ### Optional: APP_TLS_SECRET_NAME; - secretName: '{{ env "APP_TLS_SECRET_NAME" | default (requiredEnv "COLOR" | printf "example-%s-server-tls") }}' hosts: ### Required: APP_HOST; From 84aa9b347996b615f5dc3c590ef55870f1010097 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:00:24 -0700 Subject: [PATCH 02/60] push to dockerhub --- codefresh/build.yaml | 5 +++-- codefresh/release.yaml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/codefresh/build.yaml b/codefresh/build.yaml index f2bb7d5..2e8952f 100644 --- a/codefresh/build.yaml +++ b/codefresh/build.yaml @@ -20,7 +20,7 @@ steps: stage: Build type: build description: Build image - image_name: ${{CF_REPO_NAME}} + image_name: cloudposse/${{CF_REPO_NAME}} dockerfile: Dockerfile push_image_commit: @@ -28,5 +28,6 @@ steps: stage: Push type: push candidate: ${{build_image}} + registry: dockerhub tags: - - "${{CF_REVISION}}" \ No newline at end of file + - "${{CF_REVISION}}" diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 0ebba89..8e44eeb 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -31,6 +31,7 @@ steps: type: push image_name: ${{CF_REPO_NAME}} candidate: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" + registry: dockerhub tags: - "${{CF_RELEASE_TAG}}" From 5cd64f0ec86d0924eff9ef34b1ec85afd87a5950 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:16:59 -0700 Subject: [PATCH 03/60] use helm2 --- deploy/ctl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy/ctl b/deploy/ctl index 597472d..b061f03 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -32,7 +32,8 @@ tasks: deps: description: "Install alpine dependencies" script: | - ! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse + ! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm2@cloudposse helmfile@cloudposse + update-alternatives --set helm /usr/share/helm/2/bin/helm2 helm init --client-only color: From deccf81a8e7203cc60294d793fe9bacd7d37664d Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:18:09 -0700 Subject: [PATCH 04/60] use helm3 --- deploy/ctl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/deploy/ctl b/deploy/ctl index b061f03..620c54e 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -32,9 +32,7 @@ tasks: deps: description: "Install alpine dependencies" script: | - ! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm2@cloudposse helmfile@cloudposse - update-alternatives --set helm /usr/share/helm/2/bin/helm2 - helm init --client-only + ! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse color: description: "Lookup the current color" From 82c47ed6f52b87448833d7a3d147a85089a627ec Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:34:48 -0700 Subject: [PATCH 05/60] push to dockerhub --- codefresh/pull-request.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/pull-request.yaml b/codefresh/pull-request.yaml index 080d1f9..d689b03 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/pull-request.yaml @@ -40,8 +40,9 @@ steps: title: Build image type: build description: Build app - image_name: ${{CF_REPO_NAME}} + image_name: ${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} tag: ${{CF_SHORT_REVISION}} + registry: dockerhub dockerfile: Dockerfile no_cache: false no_cf_cache: false @@ -176,4 +177,3 @@ steps: condition: any: deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true" - From 317b07c43d0abaaf56bf94dc9428239a3ea45736 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:40:07 -0700 Subject: [PATCH 06/60] use dockerhub --- codefresh/build.yaml | 2 +- codefresh/pull-request.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codefresh/build.yaml b/codefresh/build.yaml index 2e8952f..ec2c883 100644 --- a/codefresh/build.yaml +++ b/codefresh/build.yaml @@ -20,7 +20,7 @@ steps: stage: Build type: build description: Build image - image_name: cloudposse/${{CF_REPO_NAME}} + image_name: ${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} dockerfile: Dockerfile push_image_commit: diff --git a/codefresh/pull-request.yaml b/codefresh/pull-request.yaml index d689b03..4f10f15 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/pull-request.yaml @@ -40,9 +40,8 @@ steps: title: Build image type: build description: Build app - image_name: ${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} + image_name: $${{CF_DOCKER_REPO_URL}}/{{CF_REPO_NAME}} tag: ${{CF_SHORT_REVISION}} - registry: dockerhub dockerfile: Dockerfile no_cache: false no_cf_cache: false @@ -106,6 +105,7 @@ steps: title: Push image with commit tag stage: Deploy type: push + registry: dockerhub candidate: ${{build_image}} tags: - "${{CF_REVISION}}" From cf425206fb7e7e1fe7c18dacccd8a9e25da82bfc Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:43:11 -0700 Subject: [PATCH 07/60] fix typo --- codefresh/pull-request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/pull-request.yaml b/codefresh/pull-request.yaml index 4f10f15..d911a40 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/pull-request.yaml @@ -40,7 +40,7 @@ steps: title: Build image type: build description: Build app - image_name: $${{CF_DOCKER_REPO_URL}}/{{CF_REPO_NAME}} + image_name: ${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} tag: ${{CF_SHORT_REVISION}} dockerfile: Dockerfile no_cache: false From b84e25de54c900922243bddff9a37a2bef846ee1 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:53:19 -0700 Subject: [PATCH 08/60] deprecate deploy ctl --- Dockerfile | 7 ++-- deploy/.ctlenv | 1 - deploy/ctl | 98 -------------------------------------------------- 3 files changed, 3 insertions(+), 103 deletions(-) delete mode 100644 deploy/.ctlenv delete mode 100755 deploy/ctl diff --git a/Dockerfile b/Dockerfile index 943f92a..50436b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:alpine3.8 AS builder +FROM golang:alpine3.11 AS builder # Copy source into builder ADD . /src @@ -8,12 +8,11 @@ RUN cd /src && \ go build -o example-app # Build the final image -FROM alpine:3.8 as final +FROM alpine:3.11 as final # Install the cloudposse alpine repository ADD https://apk.cloudposse.com/ops@cloudposse.com.rsa.pub /etc/apk/keys/ -RUN echo "@cloudposse https://apk.cloudposse.com/3.8/vendor" >> /etc/apk/repositories -RUN apk add --update bash variant@cloudposse +RUN echo "@cloudposse https://apk.cloudposse.com/3.11/vendor" >> /etc/apk/repositories # Expose port of the app EXPOSE 8080 diff --git a/deploy/.ctlenv b/deploy/.ctlenv deleted file mode 100644 index 9001211..0000000 --- a/deploy/.ctlenv +++ /dev/null @@ -1 +0,0 @@ -dev \ No newline at end of file diff --git a/deploy/ctl b/deploy/ctl deleted file mode 100755 index 620c54e..0000000 --- a/deploy/ctl +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env variant -# vim:set ft=yaml - -parameters: -- name: config - default: .color - description: "Config file that keeps track of the current color" - -- name: namespace - default: "default" - description: "Kubernetes namespace" - -tasks: - - # https://istio.io/docs/tasks/traffic-management/ingress/#determining-the-ingress-ip-and-ports-when-using-an-external-load-balancer - istio-ingress: - description: Output the FQHN of the Istio Ingress Gateway - script: | - kubectl --namespace istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' - - # https://istio.io/docs/setup/kubernetes/quick-start/ - istio-injection: - description: Enable Istio Sidecar Injection for a namespace - script: | - kubectl label namespace {{ get "namespace" }} istio-injection=enabled --overwrite=true - - use-context: - description: "Configure kube-context" - script: | - kubectl config use-context ${KUBE_CONTEXT} - - deps: - description: "Install alpine dependencies" - script: | - ! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse - - color: - description: "Lookup the current color" - script: | - config=${CF_VOLUME_PATH:-.}/{{ get "config" }} - if [ -f ${config} ]; then - cat ${config} - else - echo "Initializing as blue" >&2 - echo "blue" | tee ${config} - fi - - rolling: - description: "Trigger a standard rolling deployment without istio" - - parameters: - - name: color - type: string - default: "black" - description: "Selected color to deploy" - - steps: - - task: deps - - task: use-context - - script: | - export COLOR={{ get "color" }} - echo "Updating [${KUBE_CONTEXT}] context {{ get "namespace" }} namespace with color=${COLOR}" - # Deploy the app and update istio virtual service - helmfile --namespace {{ get "namespace" }} --selector pull-request=true sync - - blue-green: - description: "Trigger a blue-green deployment" - parameters: - - name: color - type: string - description: "Selected color to deploy" - - - name: blue - type: string - default: green - description: "Flip blue color to this color" - - - name: green - type: string - default: blue - description: "Flip green color to this color" - - steps: - - task: deps - - task: use-context - - task: istio-injection - - script: | - config=${CF_VOLUME_PATH:-.}/{{ get "config" }} - cur_color={{ get "color" }} - new_color={{ get "color" | get }} - echo "Config file is ${config}" - echo "Updating [${KUBE_CONTEXT}] context {{ get "namespace" }} namespace: $cur_color => $new_color" - export COLOR=$new_color - export APP_HOST=${COLOR}.example.${BASE_HOST} - export RELEASE_NAME=example-${COLOR} - # Deploy the app and update istio virtual service - helmfile --namespace {{ get "namespace" }} sync - echo "$new_color" > ${config} From b1a21a56c6688163f151d0d4cfa5c31c4ed942b4 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:57:27 -0700 Subject: [PATCH 09/60] deprecate deploy ctl --- codefresh/deploy.yaml | 6 ++++-- codefresh/pull-request.yaml | 5 ++++- deploy/helmfile.yaml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 833665a..dd1f79f 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -39,8 +39,10 @@ steps: commands: # Announce the release version - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" - # Deploy chart to cluster - - "/deploy/ctl --namespace=${{NAMESPACE}} blue-green" + - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse + - "kubectl config use-context ${{KUBE_CONTEXT}}" + # Deploy chart to cluster in a dedicated namespace + - "helmfile --namespace ${{NAMESPACE}} --selector pull-request=true sync" when: steps: - name: ask_for_permission diff --git a/codefresh/pull-request.yaml b/codefresh/pull-request.yaml index d911a40..86fd2a6 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/pull-request.yaml @@ -133,8 +133,11 @@ steps: commands: # Announce the release version - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" + - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse + - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - - "/deploy/ctl --namespace=${{NAMESPACE}} rolling" + - "helmfile --namespace ${{NAMESPACE}} --selector pull-request=true sync" +" when: condition: any: diff --git a/deploy/helmfile.yaml b/deploy/helmfile.yaml index df9fb27..6386510 100644 --- a/deploy/helmfile.yaml +++ b/deploy/helmfile.yaml @@ -1,5 +1,5 @@ # Ordered list of releases. helmfiles: - - "releases/pull-secret.yaml" +# - "releases/pull-secret.yaml" - "releases/app.yaml" - "releases/istio.yaml" From 265b19f54f2675c852daafa1333d77a1407c9de7 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 17:59:37 -0700 Subject: [PATCH 10/60] fix yaml --- codefresh/pull-request.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/codefresh/pull-request.yaml b/codefresh/pull-request.yaml index 86fd2a6..a0d0a06 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/pull-request.yaml @@ -137,7 +137,6 @@ steps: - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - "helmfile --namespace ${{NAMESPACE}} --selector pull-request=true sync" -" when: condition: any: From 9ad4d1826ef008f6322708b5a1f295a553935b6a Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 18:03:33 -0700 Subject: [PATCH 11/60] add missing quote --- codefresh/pull-request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/pull-request.yaml b/codefresh/pull-request.yaml index a0d0a06..a6d9e48 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/pull-request.yaml @@ -133,7 +133,7 @@ steps: commands: # Announce the release version - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" - - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse + - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - "helmfile --namespace ${{NAMESPACE}} --selector pull-request=true sync" From 0086a92065d9f520083d45f083be46651bcced33 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 18:06:58 -0700 Subject: [PATCH 12/60] set default color --- codefresh/pull-request.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/codefresh/pull-request.yaml b/codefresh/pull-request.yaml index a6d9e48..88ca04a 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/pull-request.yaml @@ -21,6 +21,7 @@ steps: stage: Prepare image: alpine commands: + - cf_export COLOR=default - cf_export GIT_BRANCH=${{CF_BRANCH}} - cf_export PROJECT=${{CF_REPO_NAME}} - cf_export APP_NAME=${{CF_REPO_NAME}} From 02e160701108395dccbf2d6b27e8ca0236cafa60 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 18:09:58 -0700 Subject: [PATCH 13/60] fix annotation --- deploy/releases/app.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index bba6fd1..681d4b1 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -57,12 +57,9 @@ releases: ingress: default: enabled: true - labels: - dns: "route53" annotations: kubernetes.io/ingress.class: nginx kubernetes.io/tls-acme: "true" - external-dns.alpha.kubernetes.io/target: '{{ requiredEnv "NGINX_INGRESS_HOSTNAME" }}' external-dns.alpha.kubernetes.io/ttl: "60" hosts: ### Required: APP_HOST; From 277b28829021277edfa3dbd630bb02bd66ef5275 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 18:16:00 -0700 Subject: [PATCH 14/60] upgrade monochart --- deploy/releases/app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index 681d4b1..2cfd24c 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -13,7 +13,7 @@ releases: color: "{{ requiredEnv "COLOR" }}" pull-request: "true" chart: "cloudposse-incubator/monochart" - version: "0.12.0" + version: "0.22.0" wait: true force: true recreatePods: false From c08e76bd6bfd5e2f2547e4b671967b533065e6e8 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 19:04:00 -0700 Subject: [PATCH 15/60] set to real color --- codefresh/deploy.yaml | 1 + codefresh/pull-request.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index dd1f79f..e4b1a75 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -14,6 +14,7 @@ steps: - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_RELEASE_TAG}} - cf_export GATEWAY_HOST=example.${{BASE_HOST}} + - cf_export COLOR=blue ask_for_permission: type: pending-approval diff --git a/codefresh/pull-request.yaml b/codefresh/pull-request.yaml index 88ca04a..fa96867 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/pull-request.yaml @@ -21,7 +21,7 @@ steps: stage: Prepare image: alpine commands: - - cf_export COLOR=default + - cf_export COLOR=blue - cf_export GIT_BRANCH=${{CF_BRANCH}} - cf_export PROJECT=${{CF_REPO_NAME}} - cf_export APP_NAME=${{CF_REPO_NAME}} From c8cfac5c8c7856e794ec7e23e375e3f655dc989a Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 19:42:18 -0700 Subject: [PATCH 16/60] Deploy t staging sequentially --- codefresh/deploy.yaml | 2 +- codefresh/{pull-request.yaml => preview.yaml} | 16 +++++++++++ codefresh/release.yaml | 28 +++++++++++-------- 3 files changed, 34 insertions(+), 12 deletions(-) rename codefresh/{pull-request.yaml => preview.yaml} (90%) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index e4b1a75..dfe427d 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -13,7 +13,7 @@ steps: - cf_export NAMESPACE=${{STAGE}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_RELEASE_TAG}} - - cf_export GATEWAY_HOST=example.${{BASE_HOST}} + - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue ask_for_permission: diff --git a/codefresh/pull-request.yaml b/codefresh/preview.yaml similarity index 90% rename from codefresh/pull-request.yaml rename to codefresh/preview.yaml index fa96867..15e8a73 100644 --- a/codefresh/pull-request.yaml +++ b/codefresh/preview.yaml @@ -180,3 +180,19 @@ steps: condition: any: deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true" + + add_url_to_comment_on_commit: + title: Comment on commit with the deployed URL + stage: Deploy + image: cloudposse/github-commenter + environment: + - GITHUB_TOKEN=${{GITHUB_TOKEN}} + - GITHUB_OWNER=${{CF_REPO_OWNER}} + - GITHUB_REPO=${{CF_REPO_NAME}} + - GITHUB_COMMENT_TYPE=commit + - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed to ${{APP_SCHEME}}://${{APP_HOST}}' + when: + condition: + all: + deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true" \ No newline at end of file diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 8e44eeb..ffba212 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -1,21 +1,20 @@ version: '1.0' stages: - - Prepare - Promote - - Deploy + - Deploy Staging + - Deploy Production steps: main_clone: - title: "Create Context" - stage: "Prepare" + title: "Prepare Release" + stage: "Promote" image: alpine commands: - # Extract the postfix of a semver (e.g. 0.0.0-stage => stage) - - cf_export STAGE=$(echo ${{CF_RELEASE_TAG}} | sed -E 's/^[^-]+-?//') + - echo "Preparing Deployment of ${{CF_REVISION}} (${{CF_REVISION}})" pull_image_sha: - title: Pull image with commit sha + title: Pull image with commit SHA stage: "Promote" image: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" retry: @@ -39,9 +38,16 @@ steps: title: Deploy Release stage: "Deploy" image: 'codefresh/cli:latest' + environment: + STAGE: staging commands: - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} - when: - condition: - all: - stageDefined: "'${{STAGE}}' != ''" + + deploy: + title: Deploy Release to Production + stage: "Deploy Production" + image: 'codefresh/cli:latest' + environment: + STAGE: prod + commands: + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} \ No newline at end of file From c552957aee2b049c4323f66d6b80c03c39342c3c Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 19:47:11 -0700 Subject: [PATCH 17/60] rename pull-request to preview --- README.md | 2 +- codefresh/deploy.yaml | 2 +- codefresh/destroy.yaml | 2 +- codefresh/preview.yaml | 2 +- deploy/releases/app.yaml | 2 +- deploy/releases/pull-secret.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d1b4d03..95c20d5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Example application for Codefresh CI/CD demonstrations. ### Codefresh Pipelines -1. Unlimited Staging Pipelines (pull-request, destroy) +1. Unlimited Staging Pipelines (preview, destroy) 2. Release Pipeline 3. Deploy Pipeline diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index dfe427d..0cc05c1 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -43,7 +43,7 @@ steps: - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - - "helmfile --namespace ${{NAMESPACE}} --selector pull-request=true sync" + - "helmfile --namespace ${{NAMESPACE}} --selector preview=true sync" when: steps: - name: ask_for_permission diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index ce6d558..3285005 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -9,7 +9,7 @@ steps: stage: Destroy image: codefresh/cli:latest commands: - - codefresh get builds --pipeline=destroy --pipeline=pull-request --branch=${{CF_BRANCH}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id' + - codefresh get builds --pipeline=destroy --pipeline=preview --branch=${{CF_BRANCH}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id' retry: maxAttempts: 10 delay: 20 diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 15e8a73..bf3205d 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -156,7 +156,7 @@ steps: - GITHUB_CONTEXT=Staging Environment - GITHUB_STATE=success - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace - - GITHUB_TARGET_URL=http://${{APP_HOST}} + - GITHUB_TARGET_URL=http://${{APP_HOST}}/dashboard when: condition: all: diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index 2cfd24c..2ca783f 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -11,7 +11,7 @@ releases: - name: '{{ requiredEnv "RELEASE_NAME" }}' labels: color: "{{ requiredEnv "COLOR" }}" - pull-request: "true" + preview: "true" chart: "cloudposse-incubator/monochart" version: "0.22.0" wait: true diff --git a/deploy/releases/pull-secret.yaml b/deploy/releases/pull-secret.yaml index 3318e49..ba19ac0 100644 --- a/deploy/releases/pull-secret.yaml +++ b/deploy/releases/pull-secret.yaml @@ -33,7 +33,7 @@ releases: labels: chart: "dockercfg" component: "secrets" - pull-request: "true" + preview: "true" values: - image: From 17e3d7202d48f307752e066c5cf8dbbb1f971c0e Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 19:50:59 -0700 Subject: [PATCH 18/60] rename pull-request to preview --- codefresh/preview.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index bf3205d..8595465 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -116,7 +116,7 @@ steps: stage: Deploy image: codefresh/cli:latest commands: - - codefresh get builds --pipeline=destroy --pipeline=pull-request --branch=${{CF_BRANCH}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id' + - codefresh get builds --pipeline=destroy --pipeline=preview --branch=${{CF_BRANCH}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id' retry: maxAttempts: 10 delay: 20 @@ -137,7 +137,7 @@ steps: - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - - "helmfile --namespace ${{NAMESPACE}} --selector pull-request=true sync" + - "helmfile --namespace ${{NAMESPACE}} --selector preview=true sync" when: condition: any: From 76b8acebf8c03a91c2b4e68e435fd7523fec3126 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 21:18:41 -0700 Subject: [PATCH 19/60] downgrade helm --- codefresh/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 8595465..3156208 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -134,7 +134,7 @@ steps: commands: # Announce the release version - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" - - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse" + - "apk add --update curl make bash git kubectl@cloudposse =3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - "helmfile --namespace ${{NAMESPACE}} --selector preview=true sync" From bc50e0d2f67bd4546fe3eb71ed6e8b7fe7622d04 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 21:19:35 -0700 Subject: [PATCH 20/60] downgrade helm --- codefresh/preview.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 3156208..e8b46d0 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -134,7 +134,8 @@ steps: commands: # Announce the release version - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" - - "apk add --update curl make bash git kubectl@cloudposse =3.1.3-r0 helmfile@cloudposse" + # Downgrade to helm 3.1.3: https://github.com/helm/helm/issues/7956 + - "apk add --update curl make bash git kubectl@cloudposse=3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - "helmfile --namespace ${{NAMESPACE}} --selector preview=true sync" From 4a8f5c395f396d992257b4d8c85429bbd3d4b6d2 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 21:22:39 -0700 Subject: [PATCH 21/60] fix command --- codefresh/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index e8b46d0..0e9b76b 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -135,7 +135,7 @@ steps: # Announce the release version - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" # Downgrade to helm 3.1.3: https://github.com/helm/helm/issues/7956 - - "apk add --update curl make bash git kubectl@cloudposse=3.1.3-r0 helmfile@cloudposse" + - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - "helmfile --namespace ${{NAMESPACE}} --selector preview=true sync" From 290fbbbef4d6e08506599b3e41ff95097a6b0f92 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 21:39:36 -0700 Subject: [PATCH 22/60] change format --- codefresh/deploy.yaml | 21 +++++++++++++++++++++ codefresh/preview.yaml | 6 ++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 0cc05c1..b349250 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -15,6 +15,7 @@ steps: - cf_export IMAGE_TAG=${{CF_RELEASE_TAG}} - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue + - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d @${{CF_BUILD_TIMESTAMP}}) ask_for_permission: type: pending-approval @@ -60,3 +61,23 @@ steps: commands: - make codefresh/notify/slack/deploy/webapp + set_github_deployment_status_to_success: + title: Set GitHub deployment status to "success" + stage: Deploy + image: cloudposse/github-status-updater + environment: + - GITHUB_ACTION=update_state + - GITHUB_TOKEN=${{GITHUB_TOKEN}} + - GITHUB_OWNER=${{CF_REPO_OWNER}} + - GITHUB_REPO=${{CF_REPO_NAME}} + - GITHUB_REF=${{CF_REVISION}} + - GITHUB_CONTEXT=${{STAGE}} + - GITHUB_STATE=success + - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace by @${{CF_BUILD_INITIATOR}} at ${{CF_BUILD_DATE_TIME}} + - GITHUB_TARGET_URL=http://${{APP_HOST}}/dashboard + + when: + condition: + all: + deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true" + githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'" \ No newline at end of file diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 0e9b76b..5d9eb87 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -22,6 +22,7 @@ steps: image: alpine commands: - cf_export COLOR=blue + - cf_export STAGE=preview - cf_export GIT_BRANCH=${{CF_BRANCH}} - cf_export PROJECT=${{CF_REPO_NAME}} - cf_export APP_NAME=${{CF_REPO_NAME}} @@ -32,6 +33,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} + - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d @${{CF_BUILD_TIMESTAMP}}) build: type: parallel @@ -154,9 +156,9 @@ steps: - GITHUB_OWNER=${{CF_REPO_OWNER}} - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_REF=${{CF_REVISION}} - - GITHUB_CONTEXT=Staging Environment + - GITHUB_CONTEXT=${{STAGE}} - GITHUB_STATE=success - - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace + - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace by @${{CF_BUILD_INITIATOR}} at ${{CF_BUILD_DATE_TIME}} - GITHUB_TARGET_URL=http://${{APP_HOST}}/dashboard when: condition: From 6850186a135f6262bdec8f4eb44ecb9dd9eb1aee Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 21:44:30 -0700 Subject: [PATCH 23/60] comment like crazy --- codefresh/deploy.yaml | 21 +++++++++++++++++++-- codefresh/preview.yaml | 7 ++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index b349250..4f0b4c6 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -13,6 +13,7 @@ steps: - cf_export NAMESPACE=${{STAGE}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_RELEASE_TAG}} + - cf_export APP_SCHEME=http - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d @${{CF_BUILD_TIMESTAMP}}) @@ -74,10 +75,26 @@ steps: - GITHUB_CONTEXT=${{STAGE}} - GITHUB_STATE=success - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace by @${{CF_BUILD_INITIATOR}} at ${{CF_BUILD_DATE_TIME}} - - GITHUB_TARGET_URL=http://${{APP_HOST}}/dashboard + - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard when: condition: all: deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true" - githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'" \ No newline at end of file + githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'" + +add_url_to_comment_on_commit: + title: Comment on commit with the deployed URL + stage: Deploy + image: cloudposse/github-commenter + environment: + - GITHUB_TOKEN=${{GITHUB_TOKEN}} + - GITHUB_OWNER=${{CF_REPO_OWNER}} + - GITHUB_REPO=${{CF_REPO_NAME}} + - GITHUB_COMMENT_TYPE=commit + - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to ${{APP_SCHEME}}://${{APP_HOST}}/dashboard' + when: + condition: + all: + deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true" \ No newline at end of file diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 5d9eb87..7f52001 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -30,6 +30,7 @@ steps: - cf_export PIPELINE_ENV=integration - cf_export NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} - cf_export RELEASE_NAME=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} + - cf_export APP_SCHEME=http - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} @@ -97,7 +98,7 @@ steps: - GITHUB_CONTEXT=Staging Environment - GITHUB_STATE=pending - GITHUB_DESCRIPTION=Deploying changes to ${{NAMESPACE}} namespace - - GITHUB_TARGET_URL=http://${{APP_HOST}} + - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}} when: condition: all: @@ -159,7 +160,7 @@ steps: - GITHUB_CONTEXT=${{STAGE}} - GITHUB_STATE=success - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace by @${{CF_BUILD_INITIATOR}} at ${{CF_BUILD_DATE_TIME}} - - GITHUB_TARGET_URL=http://${{APP_HOST}}/dashboard + - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard when: condition: all: @@ -194,7 +195,7 @@ steps: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed to ${{APP_SCHEME}}://${{APP_HOST}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to ${{APP_SCHEME}}://${{APP_HOST}}/dashboard' when: condition: all: From 82088de8921ee2ed280f341cb0bddd072cca2bca Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 21:51:44 -0700 Subject: [PATCH 24/60] update context --- codefresh/deploy.yaml | 2 +- codefresh/preview.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 4f0b4c6..ef6789b 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -72,7 +72,7 @@ steps: - GITHUB_OWNER=${{CF_REPO_OWNER}} - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_REF=${{CF_REVISION}} - - GITHUB_CONTEXT=${{STAGE}} + - GITHUB_CONTEXT=${{STAGE}}/env - GITHUB_STATE=success - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace by @${{CF_BUILD_INITIATOR}} at ${{CF_BUILD_DATE_TIME}} - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 7f52001..e35aac5 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -95,7 +95,7 @@ steps: - GITHUB_OWNER=${{CF_REPO_OWNER}} - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_REF=${{CF_REVISION}} - - GITHUB_CONTEXT=Staging Environment + - GITHUB_CONTEXT=${{STAGE}}/env - GITHUB_STATE=pending - GITHUB_DESCRIPTION=Deploying changes to ${{NAMESPACE}} namespace - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}} @@ -157,7 +157,7 @@ steps: - GITHUB_OWNER=${{CF_REPO_OWNER}} - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_REF=${{CF_REVISION}} - - GITHUB_CONTEXT=${{STAGE}} + - GITHUB_CONTEXT=${{STAGE}}/env - GITHUB_STATE=success - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace by @${{CF_BUILD_INITIATOR}} at ${{CF_BUILD_DATE_TIME}} - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard From 828e0814de62bccedf6d9940d83bcfe395240730 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:02:16 -0700 Subject: [PATCH 25/60] update descriptions --- codefresh/deploy.yaml | 4 ++-- codefresh/preview.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index ef6789b..a0f998e 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -74,7 +74,7 @@ steps: - GITHUB_REF=${{CF_REVISION}} - GITHUB_CONTEXT=${{STAGE}}/env - GITHUB_STATE=success - - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace by @${{CF_BUILD_INITIATOR}} at ${{CF_BUILD_DATE_TIME}} + - GITHUB_DESCRIPTION=Deployed `${{NAMESPACE}}` (@${{CF_BUILD_INITIATOR}}) - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard when: @@ -93,7 +93,7 @@ add_url_to_comment_on_commit: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to ${{APP_SCHEME}}://${{APP_HOST}}/dashboard' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to `${{STAGE}}` at ${{APP_SCHEME}}://${{APP_HOST}}/dashboard on $${{CF_BUILD_DATE_TIME}}' when: condition: all: diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index e35aac5..5f1398d 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -159,7 +159,7 @@ steps: - GITHUB_REF=${{CF_REVISION}} - GITHUB_CONTEXT=${{STAGE}}/env - GITHUB_STATE=success - - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace by @${{CF_BUILD_INITIATOR}} at ${{CF_BUILD_DATE_TIME}} + - GITHUB_DESCRIPTION=Deployed `${{NAMESPACE}}` (@${{CF_BUILD_INITIATOR}}) - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard when: condition: @@ -195,7 +195,7 @@ steps: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to ${{APP_SCHEME}}://${{APP_HOST}}/dashboard' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to `${{STAGE}}` at ${{APP_SCHEME}}://${{APP_HOST}}/dashboard on $${{CF_BUILD_DATE_TIME}}' when: condition: all: From 64422db459b1ada334e0b638bc9f4c7945450f50 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:05:38 -0700 Subject: [PATCH 26/60] wording --- codefresh/deploy.yaml | 2 +- codefresh/preview.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index a0f998e..9f1a154 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -93,7 +93,7 @@ add_url_to_comment_on_commit: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to `${{STAGE}}` at ${{APP_SCHEME}}://${{APP_HOST}}/dashboard on $${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} in the `${{NAMESPACE}}` namespace on `${{STAGE}}` to ${{APP_SCHEME}}://${{APP_HOST}}/dashboard at $${{CF_BUILD_DATE_TIME}}' when: condition: all: diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 5f1398d..23ff7ed 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -195,7 +195,7 @@ steps: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to `${{STAGE}}` at ${{APP_SCHEME}}://${{APP_HOST}}/dashboard on $${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} in the `${{NAMESPACE}}` namespace on `${{STAGE}}` to ${{APP_SCHEME}}://${{APP_HOST}}/dashboard at $${{CF_BUILD_DATE_TIME}}' when: condition: all: From ee6eba84b95d90fb860f890845a929d3fba654ba Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:08:24 -0700 Subject: [PATCH 27/60] fix timestamp --- codefresh/deploy.yaml | 2 +- codefresh/preview.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 9f1a154..6743b97 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -16,7 +16,7 @@ steps: - cf_export APP_SCHEME=http - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue - - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d @${{CF_BUILD_TIMESTAMP}}) + - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d "@${{CF_BUILD_TIMESTAMP}}") ask_for_permission: type: pending-approval diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 23ff7ed..ce77c5b 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -34,7 +34,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} - - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d @${{CF_BUILD_TIMESTAMP}}) + - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d "@${{CF_BUILD_TIMESTAMP}}") build: type: parallel From 32139cd08e65f7cab0f89ed64f8fe263dd82e651 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:10:17 -0700 Subject: [PATCH 28/60] fix date time --- codefresh/deploy.yaml | 2 +- codefresh/preview.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 6743b97..4e44600 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -16,7 +16,7 @@ steps: - cf_export APP_SCHEME=http - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue - - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d "@${{CF_BUILD_TIMESTAMP}}") + - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))") ask_for_permission: type: pending-approval diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index ce77c5b..8a47c3e 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -34,7 +34,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} - - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d "@${{CF_BUILD_TIMESTAMP}}") + - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))") build: type: parallel From eab09ae91e6beb3e097af7d03b125870fb33cf14 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:15:59 -0700 Subject: [PATCH 29/60] clean up format --- codefresh/deploy.yaml | 6 +++--- codefresh/preview.yaml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 4e44600..97694fb 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -16,7 +16,7 @@ steps: - cf_export APP_SCHEME=http - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue - - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))") + - cf_export CF_BUILD_DATE_TIME="$(date "%Y-%m-%d %H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))")" ask_for_permission: type: pending-approval @@ -74,7 +74,7 @@ steps: - GITHUB_REF=${{CF_REVISION}} - GITHUB_CONTEXT=${{STAGE}}/env - GITHUB_STATE=success - - GITHUB_DESCRIPTION=Deployed `${{NAMESPACE}}` (@${{CF_BUILD_INITIATOR}}) + - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} by @${{CF_BUILD_INITIATOR}} - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard when: @@ -93,7 +93,7 @@ add_url_to_comment_on_commit: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} in the `${{NAMESPACE}}` namespace on `${{STAGE}}` to ${{APP_SCHEME}}://${{APP_HOST}}/dashboard at $${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} in the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at $${{CF_BUILD_DATE_TIME}}' when: condition: all: diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 8a47c3e..c7a5e61 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -159,7 +159,7 @@ steps: - GITHUB_REF=${{CF_REVISION}} - GITHUB_CONTEXT=${{STAGE}}/env - GITHUB_STATE=success - - GITHUB_DESCRIPTION=Deployed `${{NAMESPACE}}` (@${{CF_BUILD_INITIATOR}}) + - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} by @${{CF_BUILD_INITIATOR}} - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard when: condition: @@ -195,7 +195,7 @@ steps: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} in the `${{NAMESPACE}}` namespace on `${{STAGE}}` to ${{APP_SCHEME}}://${{APP_HOST}}/dashboard at $${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} in the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at $${{CF_BUILD_DATE_TIME}}' when: condition: all: From 82e1a626c924c428c854f755ef2b9bb159979793 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:17:45 -0700 Subject: [PATCH 30/60] wording --- codefresh/deploy.yaml | 2 +- codefresh/preview.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 97694fb..20e942f 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -93,7 +93,7 @@ add_url_to_comment_on_commit: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} in the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at $${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at $${{CF_BUILD_DATE_TIME}}' when: condition: all: diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index c7a5e61..bdaac75 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -34,7 +34,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} - - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d %H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))") + - cf_export CF_BUILD_DATE_TIME="$(date "%Y-%m-%d %H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))")" build: type: parallel @@ -195,7 +195,7 @@ steps: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} in the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at $${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at $${{CF_BUILD_DATE_TIME}}' when: condition: all: From 0bf3ad0bbc0b89fdacc147a11da2a86674a0be44 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:20:44 -0700 Subject: [PATCH 31/60] remove $ --- codefresh/deploy.yaml | 4 ++-- codefresh/preview.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 20e942f..223d3ac 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -16,7 +16,7 @@ steps: - cf_export APP_SCHEME=http - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue - - cf_export CF_BUILD_DATE_TIME="$(date "%Y-%m-%d %H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))")" + - cf_export CF_BUILD_DATE_TIME="$(date "%Y-%m-%d/%H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))")" ask_for_permission: type: pending-approval @@ -93,7 +93,7 @@ add_url_to_comment_on_commit: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at $${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at ${{CF_BUILD_DATE_TIME}}' when: condition: all: diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index bdaac75..0e13879 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -34,7 +34,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} - - cf_export CF_BUILD_DATE_TIME="$(date "%Y-%m-%d %H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))")" + - cf_export CF_BUILD_DATE_TIME="$(date "%Y-%m-%d/%H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))")" build: type: parallel @@ -195,7 +195,7 @@ steps: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at $${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at ${{CF_BUILD_DATE_TIME}}' when: condition: all: From 00eac518104b3e256e92668e83e3c573956f397d Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:24:30 -0700 Subject: [PATCH 32/60] remove quotes --- codefresh/deploy.yaml | 2 +- codefresh/preview.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 223d3ac..d57f0f9 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -16,7 +16,7 @@ steps: - cf_export APP_SCHEME=http - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue - - cf_export CF_BUILD_DATE_TIME="$(date "%Y-%m-%d/%H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))")" + - cf_export CF_BUILD_DATE_TIME=$(date "%Y-%m-%d/%H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))") ask_for_permission: type: pending-approval diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 0e13879..4fd30c4 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -34,7 +34,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} - - cf_export CF_BUILD_DATE_TIME="$(date "%Y-%m-%d/%H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))")" + - cf_export CF_BUILD_DATE_TIME=$(date "%Y-%m-%d/%H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))") build: type: parallel From 2f9d7727a3b0aeb21e002dc25e388807e8c2c6b1 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:28:39 -0700 Subject: [PATCH 33/60] add destroy action --- codefresh/destroy.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index 3285005..9683bb8 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -38,3 +38,22 @@ steps: deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == false" validatePRAction: "'${{CF_PULL_REQUEST_ACTION}}' == 'closed'" + set_github_destroy_status_to_success: + title: Set GitHub destroy status to "success" + stage: Destroy + image: cloudposse/github-status-updater + environment: + - GITHUB_ACTION=update_state + - GITHUB_TOKEN=${{GITHUB_TOKEN}} + - GITHUB_OWNER=${{CF_REPO_OWNER}} + - GITHUB_REPO=${{CF_REPO_NAME}} + - GITHUB_REF=${{CF_REVISION}} + - GITHUB_CONTEXT=${{STAGE}}/env + - GITHUB_STATE=success + - GITHUB_DESCRIPTION=Destroyed ${{NAMESPACE}} by @${{CF_BUILD_INITIATOR}} + - GITHUB_TARGET_URL=${{CF_BUILD_URL}} + when: + condition: + any: + deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == false" + validatePRAction: "'${{CF_PULL_REQUEST_ACTION}}' == 'closed'" \ No newline at end of file From ca9bc96e7a3d080bbd45f68caac8266fb97234e0 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:30:23 -0700 Subject: [PATCH 34/60] remove quotes --- codefresh/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 4fd30c4..3d330df 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -34,7 +34,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} - - cf_export CF_BUILD_DATE_TIME=$(date "%Y-%m-%d/%H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))") + - cf_export CF_BUILD_DATE_TIME=$(date "%Y-%m-%d/%H:%M:%S" -d @$((CF_BUILD_TIMESTAMP/1000))) build: type: parallel From fb397785b3128f42ded514e069c2c204f0c918a8 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:34:00 -0700 Subject: [PATCH 35/60] format time --- codefresh/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 3d330df..f695827 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -34,7 +34,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} - - cf_export CF_BUILD_DATE_TIME=$(date "%Y-%m-%d/%H:%M:%S" -d @$((CF_BUILD_TIMESTAMP/1000))) + - cf_export CF_BUILD_DATE_TIME=$(date "%Y-%m-%d/%H:%M:%S" -d @$((${{CF_BUILD_TIMESTAMP}}/1000))) build: type: parallel From 6a49265b0624e7d344f7085b68792beece36b535 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:37:58 -0700 Subject: [PATCH 36/60] restore + --- codefresh/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index f695827..6ea035d 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -34,7 +34,7 @@ steps: - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - cf_export IMAGE_TAG=${{CF_REVISION}} - - cf_export CF_BUILD_DATE_TIME=$(date "%Y-%m-%d/%H:%M:%S" -d @$((${{CF_BUILD_TIMESTAMP}}/1000))) + - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d/%H:%M:%S" -d @$((${{CF_BUILD_TIMESTAMP}}/1000))) build: type: parallel From b5b8a5ec72bf5070a497d2fef7ae64fa7d42fbe5 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:41:33 -0700 Subject: [PATCH 37/60] fix timestamp --- codefresh/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index d57f0f9..73b3081 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -16,7 +16,7 @@ steps: - cf_export APP_SCHEME=http - cf_export APP_HOST=${{STAGE}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export COLOR=blue - - cf_export CF_BUILD_DATE_TIME=$(date "%Y-%m-%d/%H:%M:%S" -d "@$((CF_BUILD_TIMESTAMP/1000))") + - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d/%H:%M:%S" -d @$((${{CF_BUILD_TIMESTAMP}}/1000))) ask_for_permission: type: pending-approval From 4f89feeabe685a55fcbe47122d7c514f05d29b81 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:47:03 -0700 Subject: [PATCH 38/60] positive reward --- codefresh/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 6ea035d..92d31e1 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -195,7 +195,7 @@ steps: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at ${{CF_BUILD_DATE_TIME}}' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at ${{CF_BUILD_DATE_TIME}}
![:thumbsup:](https://cloudposse.com/urand/familyguy.gif)' when: condition: all: From 55999834cd833404108670ae09fb918e93d71466 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 22:50:02 -0700 Subject: [PATCH 39/60] repo pinning --- codefresh/deploy.yaml | 2 +- codefresh/destroy.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 73b3081..918af8c 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -42,7 +42,7 @@ steps: commands: # Announce the release version - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" - - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse + - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - "helmfile --namespace ${{NAMESPACE}} --selector preview=true sync" diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index 9683bb8..ec525e5 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -28,7 +28,7 @@ steps: environment: - NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} commands: - - "apk add kubectl" + - "apk add kubectl@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" - "make helm/delete/namespace" - "make helm/delete/namespace/empty" From a101afbd2d75541717a6ed1238aaded28352aff3 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 23:03:54 -0700 Subject: [PATCH 40/60] use helmfile to destroy --- codefresh/destroy.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index ec525e5..49912d9 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -28,10 +28,9 @@ steps: environment: - NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} commands: - - "apk add kubectl@cloudposse" + - "apk add kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" - - "make helm/delete/namespace" - - "make helm/delete/namespace/empty" + - "helmfile --namespace ${{NAMESPACE}} --selector preview=true destroy" when: condition: any: From 7415a906939c3ca9a8c63e35c8b8271604616d1d Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 23:53:34 -0700 Subject: [PATCH 41/60] Release pipeline --- codefresh/build.yaml | 14 ++++++++++++++ codefresh/release.yaml | 24 +++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/codefresh/build.yaml b/codefresh/build.yaml index ec2c883..b024d46 100644 --- a/codefresh/build.yaml +++ b/codefresh/build.yaml @@ -4,6 +4,7 @@ stages: - Prepare - Build - Push + - Deploy steps: main_clone: @@ -31,3 +32,16 @@ steps: registry: dockerhub tags: - "${{CF_REVISION}}" + + deploy_master: + title: Deploying to Master + stage: "Deploy" + image: 'codefresh/cli:latest' + environment: + STAGE: master + commands: + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_REVISION}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} + when: + branch: + only: + - master \ No newline at end of file diff --git a/codefresh/release.yaml b/codefresh/release.yaml index ffba212..8960949 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -2,8 +2,8 @@ version: '1.0' stages: - Promote - - Deploy Staging - - Deploy Production + - Staging + - Production steps: main_clone: @@ -34,18 +34,28 @@ steps: tags: - "${{CF_RELEASE_TAG}}" - deploy: - title: Deploy Release - stage: "Deploy" + deploy_staging_confirmation: + type: pending-approval + title: Deploy Release to Staging? + stage: Staging + + deploy_staging: + title: Deploy to Staging + stage: "Staging" image: 'codefresh/cli:latest' environment: STAGE: staging commands: - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} - deploy: + deploy_production_confirmation: + type: pending-approval + title: Deploy Release to Production? + stage: Production + + deploy_production: title: Deploy Release to Production - stage: "Deploy Production" + stage: "Production" image: 'codefresh/cli:latest' environment: STAGE: prod From b82db8b9b934e33a93fe7273bb14f0d42ee80c90 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 15 Jun 2020 23:57:51 -0700 Subject: [PATCH 42/60] Add deployment pipelines --- codefresh/deploy.yaml | 17 +---------------- codefresh/preview.yaml | 2 +- codefresh/release.yaml | 4 ++-- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 918af8c..3d73d5c 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -18,11 +18,6 @@ steps: - cf_export COLOR=blue - cf_export CF_BUILD_DATE_TIME=$(date +"%Y-%m-%d/%H:%M:%S" -d @$((${{CF_BUILD_TIMESTAMP}}/1000))) - ask_for_permission: - type: pending-approval - title: Deploy release? - stage: Prepare - wait: title: Wait stage: Prepare @@ -77,12 +72,6 @@ steps: - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} by @${{CF_BUILD_INITIATOR}} - GITHUB_TARGET_URL=${{APP_SCHEME}}://${{APP_HOST}}/dashboard - when: - condition: - all: - deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true" - githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'" - add_url_to_comment_on_commit: title: Comment on commit with the deployed URL stage: Deploy @@ -93,8 +82,4 @@ add_url_to_comment_on_commit: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at ${{CF_BUILD_DATE_TIME}}' - when: - condition: - all: - deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true" \ No newline at end of file + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at ${{CF_BUILD_DATE_TIME}}' \ No newline at end of file diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index 92d31e1..cd4ec33 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -195,7 +195,7 @@ steps: - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_COMMENT_TYPE=commit - GITHUB_COMMIT_SHA=${{CF_SHORT_REVISION}} - - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at ${{CF_BUILD_DATE_TIME}}
![:thumbsup:](https://cloudposse.com/urand/familyguy.gif)' + - 'GITHUB_COMMENT=Version ${{CF_SHORT_REVISION}} deployed by @${{CF_BUILD_INITIATOR}} to the [`${{NAMESPACE}}`](${{APP_SCHEME}}://${{APP_HOST}}/dashboard) namespace on `${{STAGE}}` at ${{CF_BUILD_DATE_TIME}}
![:thumbsup:](https://cloudposse.com/urand/familyguy.gif)
' when: condition: all: diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 8960949..582071e 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -40,7 +40,7 @@ steps: stage: Staging deploy_staging: - title: Deploy to Staging + title: Releasing to Staging stage: "Staging" image: 'codefresh/cli:latest' environment: @@ -54,7 +54,7 @@ steps: stage: Production deploy_production: - title: Deploy Release to Production + title: Releasing to Production stage: "Production" image: 'codefresh/cli:latest' environment: From fc5cc33ff532814c417b8dd37f0bf7309092994f Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 00:03:04 -0700 Subject: [PATCH 43/60] fix yaml --- codefresh/release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 582071e..0b80e59 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -22,7 +22,7 @@ steps: delay: 20 exponentialFactor: 1.1 commands: - - "true" + - "true" push_image_tag: title: Push image with release tag @@ -32,7 +32,7 @@ steps: candidate: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" registry: dockerhub tags: - - "${{CF_RELEASE_TAG}}" + - "${{CF_RELEASE_TAG}}" deploy_staging_confirmation: type: pending-approval @@ -44,7 +44,7 @@ steps: stage: "Staging" image: 'codefresh/cli:latest' environment: - STAGE: staging + - STAGE: staging commands: - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} @@ -58,6 +58,6 @@ steps: stage: "Production" image: 'codefresh/cli:latest' environment: - STAGE: prod + - STAGE: prod commands: - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} \ No newline at end of file From fb0520e6678c1191892672ae69a36a4a04d8c6ed Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 00:15:51 -0700 Subject: [PATCH 44/60] fix env --- codefresh/release.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 0b80e59..5b35cc8 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -38,13 +38,13 @@ steps: type: pending-approval title: Deploy Release to Staging? stage: Staging - + deploy_staging: title: Releasing to Staging stage: "Staging" image: 'codefresh/cli:latest' environment: - - STAGE: staging + - STAGE=staging commands: - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} @@ -58,6 +58,6 @@ steps: stage: "Production" image: 'codefresh/cli:latest' environment: - - STAGE: prod + - STAGE=prod commands: - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} \ No newline at end of file From e1c53f726726acb0c360a4d68bf130fc1d66daf3 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 00:19:34 -0700 Subject: [PATCH 45/60] fix push --- codefresh/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 5b35cc8..e603fdc 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -28,7 +28,7 @@ steps: title: Push image with release tag stage: "Promote" type: push - image_name: ${{CF_REPO_NAME}} + image_name: ${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} candidate: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" registry: dockerhub tags: From 3948b0769999ab58f9f546225df077191fee43c1 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 00:31:33 -0700 Subject: [PATCH 46/60] braces --- codefresh/release.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codefresh/release.yaml b/codefresh/release.yaml index e603fdc..27cee75 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -11,7 +11,7 @@ steps: stage: "Promote" image: alpine commands: - - echo "Preparing Deployment of ${{CF_REVISION}} (${{CF_REVISION}})" + - echo "Preparing Deployment of ${{CF_RELEASE_TAG}} (${{CF_REVISION}})" pull_image_sha: title: Pull image with commit SHA @@ -46,7 +46,7 @@ steps: environment: - STAGE=staging commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} deploy_production_confirmation: type: pending-approval @@ -60,4 +60,4 @@ steps: environment: - STAGE=prod commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} \ No newline at end of file + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} \ No newline at end of file From 2974862c2566b0cb3dc941350020dae0daf95509 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 00:40:16 -0700 Subject: [PATCH 47/60] do not detach --- codefresh/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 27cee75..9d879e0 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -46,7 +46,7 @@ steps: environment: - STAGE=staging commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} deploy_production_confirmation: type: pending-approval @@ -60,4 +60,4 @@ steps: environment: - STAGE=prod commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} \ No newline at end of file + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} \ No newline at end of file From 0716fc52c47d3754a7505b76d4543dd82636d58e Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 00:41:33 -0700 Subject: [PATCH 48/60] fix pipeline --- codefresh/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 3d73d5c..fe7483b 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -37,7 +37,7 @@ steps: commands: # Announce the release version - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" - - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse + - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - "helmfile --namespace ${{NAMESPACE}} --selector preview=true sync" From ec3aa86a151f91e47e0a02f3d7fc422ac8de235c Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 00:54:23 -0700 Subject: [PATCH 49/60] add chart name --- codefresh/deploy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index fe7483b..01a2940 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -54,6 +54,7 @@ steps: working_directory: /build-harness environment: - PIPELINE_ENV=${{STAGE}} + - CHART_NAME=monochart commands: - make codefresh/notify/slack/deploy/webapp From 6a91cc3fd02b061d1d6886d9db6b425ac9c9444b Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 00:59:52 -0700 Subject: [PATCH 50/60] fix pipeline --- codefresh/destroy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index 49912d9..c1fe81c 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -30,7 +30,7 @@ steps: commands: - "apk add kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" - - "helmfile --namespace ${{NAMESPACE}} --selector preview=true destroy" + - "helmfile --namespace ${NAMESPACE} --selector preview=true destroy" when: condition: any: @@ -49,7 +49,7 @@ steps: - GITHUB_REF=${{CF_REVISION}} - GITHUB_CONTEXT=${{STAGE}}/env - GITHUB_STATE=success - - GITHUB_DESCRIPTION=Destroyed ${{NAMESPACE}} by @${{CF_BUILD_INITIATOR}} + - GITHUB_DESCRIPTION=Destroyed by @${{CF_BUILD_INITIATOR}} - GITHUB_TARGET_URL=${{CF_BUILD_URL}} when: condition: From a1ff9443f14845888b139878aa5a13bfa8a70df8 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 01:05:32 -0700 Subject: [PATCH 51/60] deploy pipeline fixes --- codefresh/deploy.yaml | 9 ++------- codefresh/release.yaml | 12 +++++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 01a2940..5fa9388 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -32,20 +32,15 @@ steps: deploy_helmfile: title: "Deploy with helmfile" stage: "Deploy" - image: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" + image: "${{IMAGE_NAME}}:${{IMAGE_TAG}}" working_directory: /deploy/ commands: # Announce the release version - - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" + - "echo 'Preparing to deploy ${{IMAGE_NAME}}:${{IMAGE_TAG}}'" - "apk add --update curl make bash git kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" # Deploy chart to cluster in a dedicated namespace - "helmfile --namespace ${{NAMESPACE}} --selector preview=true sync" - when: - steps: - - name: ask_for_permission - on: - - approved send_slack_notification: title: Send notification to Slack channel diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 9d879e0..b4a5a69 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -47,6 +47,11 @@ steps: - STAGE=staging commands: - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} + when: + steps: + - name: deploy_staging_confirmation + on: + - approved deploy_production_confirmation: type: pending-approval @@ -60,4 +65,9 @@ steps: environment: - STAGE=prod commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} \ No newline at end of file + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} + when: + steps: + - name: deploy_production_confirmation + on: + - approved \ No newline at end of file From 74d447ffaf2975aaf0307adc3919d5eb2cb7f051 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 01:12:45 -0700 Subject: [PATCH 52/60] Set release name --- codefresh/deploy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 5fa9388..9b79dbf 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -34,6 +34,8 @@ steps: stage: "Deploy" image: "${{IMAGE_NAME}}:${{IMAGE_TAG}}" working_directory: /deploy/ + environment: + - RELEASE_NAME=${{CF_REPO_NAME}} commands: # Announce the release version - "echo 'Preparing to deploy ${{IMAGE_NAME}}:${{IMAGE_TAG}}'" From d78d2ef540d61c9364497f2fb38e57a418c7aa72 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 01:17:08 -0700 Subject: [PATCH 53/60] fix working directory --- codefresh/destroy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index c1fe81c..9a9081d 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -24,7 +24,7 @@ steps: title: Destroy namespace stage: Destroy image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}} - working_directory: /build-harness/ + working_directory: /deploy/ environment: - NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} commands: From d247c5e37d8358a29cd9874463d9c238134417c0 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 01:25:53 -0700 Subject: [PATCH 54/60] create namespace and use iamge for destroy --- codefresh/destroy.yaml | 2 +- deploy/releases/app.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index 9a9081d..e781d2d 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -23,7 +23,7 @@ steps: destroy: title: Destroy namespace stage: Destroy - image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}} + image: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" working_directory: /deploy/ environment: - NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index 2ca783f..032a1e3 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -17,6 +17,7 @@ releases: wait: true force: true recreatePods: false + createNamespace: true values: - fullnameOverride: "example-{{ requiredEnv "COLOR" }}" image: From b23ae48a2b4a371fc4503fe14b6ab99a6f118e22 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 01:32:49 -0700 Subject: [PATCH 55/60] cannot create namespace with helm 3.1.3 --- codefresh/destroy.yaml | 2 +- deploy/releases/app.yaml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index e781d2d..6a02b36 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -21,7 +21,7 @@ steps: validatePRAction: "'${{CF_PULL_REQUEST_ACTION}}' == 'closed'" destroy: - title: Destroy namespace + title: Destroy Preview Environment stage: Destroy image: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" working_directory: /deploy/ diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index 032a1e3..2ca783f 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -17,7 +17,6 @@ releases: wait: true force: true recreatePods: false - createNamespace: true values: - fullnameOverride: "example-{{ requiredEnv "COLOR" }}" image: From de2356926e44bf32e0db6d9d43542caaba2b93a6 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 01:40:28 -0700 Subject: [PATCH 56/60] destroy tweaks --- codefresh/destroy.yaml | 1 + codefresh/preview.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index 6a02b36..0802fae 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -27,6 +27,7 @@ steps: working_directory: /deploy/ environment: - NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} + - RELEASE_NAME=${{CF_REPO_NAME}} commands: - "apk add kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" diff --git a/codefresh/preview.yaml b/codefresh/preview.yaml index cd4ec33..d00fe96 100644 --- a/codefresh/preview.yaml +++ b/codefresh/preview.yaml @@ -29,7 +29,7 @@ steps: - cf_export CHART_NAME=monochart - cf_export PIPELINE_ENV=integration - cf_export NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} - - cf_export RELEASE_NAME=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} + - cf_export RELEASE_NAME=${{CF_REPO_NAME}} - cf_export APP_SCHEME=http - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} From 52d02a4343d52a1601ef33c2d7dd849df90bacaf Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 01:52:32 -0700 Subject: [PATCH 57/60] pass more args --- codefresh/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh/release.yaml b/codefresh/release.yaml index b4a5a69..42e78b2 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -46,7 +46,7 @@ steps: environment: - STAGE=staging commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v CF_SHORT_REVISION=${{CF_SHORT_REVISION}} -v CF_COMMIT_URL=${{CF_COMMIT_URL}} -v CF_COMMIT_MESSAGE=${{CF_COMMIT_MESSAGE}} -v CF_COMMIT_AUTHOR=${{CF_COMMIT_AUTHOR}} -v CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}} -v STAGE=${STAGE} when: steps: - name: deploy_staging_confirmation @@ -65,7 +65,7 @@ steps: environment: - STAGE=prod commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${STAGE} + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v CF_SHORT_REVISION=${{CF_SHORT_REVISION}} -v CF_COMMIT_URL=${{CF_COMMIT_URL}} -v CF_COMMIT_MESSAGE=${{CF_COMMIT_MESSAGE}} -v CF_COMMIT_AUTHOR=${{CF_COMMIT_AUTHOR}} -v CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}} -v STAGE=${STAGE} when: steps: - name: deploy_production_confirmation From 41756a66898f19071410153cf72610b0468545b2 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 01:53:31 -0700 Subject: [PATCH 58/60] set color for destroy --- codefresh/destroy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index 0802fae..311e823 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -28,6 +28,7 @@ steps: environment: - NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} - RELEASE_NAME=${{CF_REPO_NAME}} + - COLOR=blue commands: - "apk add kubectl@cloudposse helm@cloudposse=3.1.3-r0 helmfile@cloudposse" - "kubectl config use-context ${{KUBE_CONTEXT}}" From 8a88bec9a937e0208e4c22057f78e27a2e534374 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 02:04:32 -0700 Subject: [PATCH 59/60] fix deployment notificaiton --- codefresh/deploy.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 9b79dbf..2427d2c 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -52,8 +52,13 @@ steps: environment: - PIPELINE_ENV=${{STAGE}} - CHART_NAME=monochart + - GIT_COMMIT_SHORT=${{CF_SHORT_REVISION}} + - GIT_COMMIT_URL=${{CF_COMMIT_URL}} + - GIT_COMMIT_MESSAGE=${{CF_COMMIT_MESSAGE}} + - GIT_COMMIT_AUTHOR=${{CF_COMMIT_AUTHOR}} + - GIT_BRANCH_TAG=${{CF_BRANCH_TAG_NORMALIZED}} commands: - - make codefresh/notify/slack/deploy/webapp + - make codefresh/notify/slack/deploy/webapp GIT_COMMIT_TIMESTAMP=$((${{CF_BUILD_TIMESTAMP}}/1000)) set_github_deployment_status_to_success: title: Set GitHub deployment status to "success" From 1b877c3501dc1cb8d6d1d917010b1aa0382c6450 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 16 Jun 2020 02:18:27 -0700 Subject: [PATCH 60/60] git commit message --- codefresh/destroy.yaml | 2 +- codefresh/release.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codefresh/destroy.yaml b/codefresh/destroy.yaml index 311e823..df30ffb 100644 --- a/codefresh/destroy.yaml +++ b/codefresh/destroy.yaml @@ -49,7 +49,7 @@ steps: - GITHUB_OWNER=${{CF_REPO_OWNER}} - GITHUB_REPO=${{CF_REPO_NAME}} - GITHUB_REF=${{CF_REVISION}} - - GITHUB_CONTEXT=${{STAGE}}/env + - GITHUB_CONTEXT=preview/env - GITHUB_STATE=success - GITHUB_DESCRIPTION=Destroyed by @${{CF_BUILD_INITIATOR}} - GITHUB_TARGET_URL=${{CF_BUILD_URL}} diff --git a/codefresh/release.yaml b/codefresh/release.yaml index 42e78b2..779b6db 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -46,7 +46,7 @@ steps: environment: - STAGE=staging commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v CF_SHORT_REVISION=${{CF_SHORT_REVISION}} -v CF_COMMIT_URL=${{CF_COMMIT_URL}} -v CF_COMMIT_MESSAGE=${{CF_COMMIT_MESSAGE}} -v CF_COMMIT_AUTHOR=${{CF_COMMIT_AUTHOR}} -v CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}} -v STAGE=${STAGE} + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v CF_SHORT_REVISION="Release ${{CF_RELEASE_TAG}}" -v CF_COMMIT_AUTHOR=${{CF_COMMIT_AUTHOR}} -v CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}} -v STAGE=${STAGE} when: steps: - name: deploy_staging_confirmation @@ -65,7 +65,7 @@ steps: environment: - STAGE=prod commands: - - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v CF_SHORT_REVISION=${{CF_SHORT_REVISION}} -v CF_COMMIT_URL=${{CF_COMMIT_URL}} -v CF_COMMIT_MESSAGE=${{CF_COMMIT_MESSAGE}} -v CF_COMMIT_AUTHOR=${{CF_COMMIT_AUTHOR}} -v CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}} -v STAGE=${STAGE} + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${STAGE} -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v CF_SHORT_REVISION=${{CF_SHORT_REVISION}} -v CF_COMMIT_URL=${{CF_COMMIT_URL}} -v CF_COMMIT_MESSAGE="Release ${{CF_RELEASE_TAG}}" -v CF_COMMIT_AUTHOR=${{CF_COMMIT_AUTHOR}} -v CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}} -v STAGE=${STAGE} when: steps: - name: deploy_production_confirmation