|
| 1 | +version: "1.0" |
| 2 | +stages: |
| 3 | + - prepare |
| 4 | + - build |
| 5 | + - deploy |
| 6 | + - qa |
| 7 | + - publish |
| 8 | +steps: |
| 9 | + main_clone: |
| 10 | + title: Clone main repository |
| 11 | + type: git-clone |
| 12 | + stage: prepare |
| 13 | + repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}" |
| 14 | + revision: "${{CF_BRANCH}}" |
| 15 | + git: github |
| 16 | + post_main_clone: |
| 17 | + title: Post main clone |
| 18 | + type: parallel |
| 19 | + stage: prepare |
| 20 | + steps: |
| 21 | + clone_cloud_harness: |
| 22 | + title: Cloning cloud-harness repository... |
| 23 | + type: git-clone |
| 24 | + stage: prepare |
| 25 | + repo: "https://github.com/MetaCell/cloud-harness.git" |
| 26 | + revision: "${{CLOUDHARNESS_BRANCH}}" |
| 27 | + working_directory: . |
| 28 | + git: github |
| 29 | + prepare_deployment: |
| 30 | + title: "Prepare helm chart" |
| 31 | + image: python:3.12 |
| 32 | + stage: prepare |
| 33 | + working_directory: . |
| 34 | + commands: |
| 35 | + - bash cloud-harness/install.sh |
| 36 | + - harness-deployment $PATHS -t ${{DEPLOYMENT_TAG}} -d ${{DOMAIN}} -r ${{REGISTRY}} -rs ${{REGISTRY_SECRET}} -n ${{NAMESPACE}} -e $ENV --no-cd $PARAMS |
| 37 | + prepare_deployment_view: |
| 38 | + commands: |
| 39 | + - "helm template ./deployment/helm --debug -n ${{NAMESPACE}}" |
| 40 | + environment: |
| 41 | + - ACTION=auth |
| 42 | + - KUBE_CONTEXT=${{NAMESPACE}} |
| 43 | + image: codefresh/cfstep-helm:3.6.2 |
| 44 | + stage: prepare |
| 45 | + title: "View helm chart" |
| 46 | + deployment: |
| 47 | + stage: deploy |
| 48 | + type: helm |
| 49 | + working_directory: ./${{CF_REPO_NAME}} |
| 50 | + title: Installing chart |
| 51 | + arguments: |
| 52 | + helm_version: 3.6.2 |
| 53 | + chart_name: deployment/helm |
| 54 | + release_name: ${{NAMESPACE}} |
| 55 | + kube_context: ${{CLUSTER_NAME}} |
| 56 | + namespace: ${{NAMESPACE}} |
| 57 | + chart_version: ${{DEPLOYMENT_TAG}} |
| 58 | + cmd_ps: --wait --timeout 600s --create-namespace |
| 59 | + custom_value_files: |
| 60 | + - ./deployment/helm/values.yaml |
| 61 | + build_test_images: |
| 62 | + title: Build test images |
| 63 | + type: parallel |
| 64 | + stage: qa |
| 65 | + steps: [] |
| 66 | + when: |
| 67 | + condition: |
| 68 | + all: |
| 69 | + whenVarExists: 'includes("${{SKIP_TESTS}}", "{{SKIP_TESTS}}") == true' |
| 70 | + wait_deployment: |
| 71 | + stage: qa |
| 72 | + title: Wait deployment to be ready |
| 73 | + image: codefresh/kubectl |
| 74 | + commands: |
| 75 | + - kubectl config use-context ${{CLUSTER_NAME}} |
| 76 | + - kubectl config set-context --current --namespace=${{NAMESPACE}} |
| 77 | + tests_api: |
| 78 | + stage: qa |
| 79 | + title: Api tests |
| 80 | + working_directory: /home/test |
| 81 | + image: "${{REGISTRY}}/cloud-harness/test-api:latest" |
| 82 | + fail_fast: false |
| 83 | + commands: |
| 84 | + - echo $APP_NAME |
| 85 | + scale: {} |
| 86 | + when: |
| 87 | + condition: |
| 88 | + all: |
| 89 | + whenVarExists: 'includes("${{SKIP_TESTS}}", "{{SKIP_TESTS}}") == true' |
| 90 | + tests_e2e: |
| 91 | + stage: qa |
| 92 | + title: End to end tests |
| 93 | + working_directory: /home/test |
| 94 | + image: "${{REGISTRY}}/cloud-harness/test-e2e:latest" |
| 95 | + fail_fast: false |
| 96 | + commands: |
| 97 | + - yarn test |
| 98 | + scale: {} |
| 99 | + when: |
| 100 | + condition: |
| 101 | + all: |
| 102 | + whenVarExists: 'includes("${{SKIP_TESTS}}", "{{SKIP_TESTS}}") == true' |
| 103 | + manual_tests: |
| 104 | + type: pending-approval |
| 105 | + stage: publish |
| 106 | + title: Manual tests performed |
| 107 | + description: Manual tests have been performed and reported |
| 108 | + timeout: |
| 109 | + duration: 168 |
| 110 | + finalState: approved |
| 111 | + approval: |
| 112 | + type: pending-approval |
| 113 | + stage: publish |
| 114 | + title: Approve release |
| 115 | + description: Approve release and tagging/publication |
| 116 | + timeout: |
| 117 | + duration: 168 |
| 118 | + finalState: approved |
| 119 | + publish_helm_chart: |
| 120 | + title: Publish Helm chart to artifact registry |
| 121 | + stage: publish |
| 122 | + image: google/cloud-sdk:alpine |
| 123 | + working_directory: . |
| 124 | + commands: |
| 125 | + - echo $GCP_SA_KEY | base64 -d > /tmp/gcp-key.json |
| 126 | + - gcloud auth activate-service-account --key-file=/tmp/gcp-key.json |
| 127 | + - gcloud auth configure-docker ${{ARTIFACT_REGISTRY_LOCATION}}-docker.pkg.dev |
| 128 | + - helm package ./deployment/helm --version ${{DEPLOYMENT_PUBLISH_TAG}} |
| 129 | + - helm push ${{NAMESPACE}}-${{DEPLOYMENT_PUBLISH_TAG}}.tgz oci://${{ARTIFACT_REGISTRY_LOCATION}}-docker.pkg.dev/${{GCP_PROJECT_ID}}/${{HELM_REPO}} |
| 130 | + - rm /tmp/gcp-key.json |
| 131 | + when: |
| 132 | + condition: |
| 133 | + all: |
| 134 | + whenVarExists: 'includes("${{DEPLOYMENT_PUBLISH_TAG}}", "{{DEPLOYMENT_PUBLISH_TAG}}") == false' |
| 135 | + whenVarExists2: 'includes("${{ARTIFACT_REGISTRY_LOCATION}}", "{{ARTIFACT_REGISTRY_LOCATION}}") == false' |
| 136 | + whenVarExists3: 'includes("${{GCP_PROJECT_ID}}", "{{GCP_PROJECT_ID}}") == false' |
| 137 | + whenVarExists4: 'includes("${{HELM_REPO}}", "{{HELM_REPO}}") == false' |
| 138 | + whenVarExists5: 'includes("${{GCP_SA_KEY}}", "{{GCP_SA_KEY}}") == false' |
| 139 | + publish: |
| 140 | + type: parallel |
| 141 | + stage: publish |
| 142 | + steps: REPLACE_ME |
| 143 | + when: |
| 144 | + condition: |
| 145 | + all: |
| 146 | + whenVarExists: 'includes("${{DEPLOYMENT_PUBLISH_TAG}}", "{{DEPLOYMENT_PUBLISH_TAG}}") == false' |
| 147 | + git-tag: |
| 148 | + title: Performing git tagging |
| 149 | + stage: publish |
| 150 | + image: alpine/git:latest |
| 151 | + commands: |
| 152 | + - git tag ${{DEPLOYMENT_PUBLISH_TAG}} |
| 153 | + - ORIGIN=$(git remote get-url origin) |
| 154 | + - PROTOCOL=https:// |
| 155 | + - REPLACEMENT=${PROTOCOL}${{REPO_TOKEN}}@ |
| 156 | + - git remote set-url origin ${ORIGIN/$PROTOCOL/$REPLACEMENT} |
| 157 | + - git push origin --tags |
| 158 | + when: |
| 159 | + condition: |
| 160 | + all: |
| 161 | + whenVarExists: 'includes("${{DEPLOYMENT_PUBLISH_TAG}}", "{{DEPLOYMENT_PUBLISH_TAG}}") == false' |
| 162 | + whenVarExists2: 'includes("${{REPO_TOKEN}}", "{{REPO_TOKEN}}") == false' |
0 commit comments