From 525c1ca6d586bb23696bc35a2424cbe5ed64f9ee Mon Sep 17 00:00:00 2001 From: Rafi Greenberg <72412693+rafi-fisker@users.noreply.github.com> Date: Fri, 21 Oct 2022 11:15:29 -0700 Subject: [PATCH] CEC-2693 devops deploy to new production (#221) * dev * bump * bump * bump * tweak * bump * staging * prod * deploy both? * cleanup * final * oops --- .env.cec-prd | 5 ++++ .github/workflows/deploy.yml | 47 ++++++++++++++++++++++++++++++------ k8s/values-cec-prd.yaml | 12 +++++++++ package.json | 3 ++- 4 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 .env.cec-prd create mode 100644 k8s/values-cec-prd.yaml diff --git a/.env.cec-prd b/.env.cec-prd new file mode 100644 index 0000000..e19a5b5 --- /dev/null +++ b/.env.cec-prd @@ -0,0 +1,5 @@ +REACT_APP_AUTH_SERVICE_URL=https://gw.cec-prd.fiskerinc.com/compute_auth +REACT_APP_CERT_SERVICE_URL=https://gw.cec-prd.fiskerinc.com/certificate +REACT_APP_UPLOAD_SERVICE_URL=https://gw.cec-prd.fiskerinc.com/ota_update +REACT_APP_AUTH_CALLBACK_URL=https://ota-admin.cec-prd.fiskerinc.com +REACT_APP_SUPERSET_URL=https://superset.cec-prd.fiskerinc.com/superset/dashboard/9/?native_filters_key=mfJ1VjGTcLUKz7gQs_DgClZhjcdNucYMrPruNibcyDnhkDwdHbAumBRVTpA5tFH_ diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5cac307..bceb3fd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,6 +5,7 @@ on: - main - "release/**" - "hotfix/**" + env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_CHANNEL: "#cloud-builds" @@ -19,13 +20,13 @@ jobs: build: runs-on: ubuntu-latest outputs: - build-env: ${{ steps.set-env.outputs.build-env }} + build-env: ${{ steps.set-env.outputs.ENVIRONMENT }} steps: - name: Slack Notification uses: rtCamp/action-slack-notify@v2 - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Azure Login uses: azure/login@v1 @@ -55,13 +56,13 @@ jobs: ENVIRONMENT=dev;; esac echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_ENV - echo "::set-output name=build-env::${ENVIRONMENT}" + echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_OUTPUT - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: . build-args: ENVIRONMENT=${{ env.ENVIRONMENT }} @@ -70,12 +71,26 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max + - name: Build and push new prod + if: github.ref == 'refs/heads/main' + uses: docker/build-push-action@v3 + with: + context: . + build-args: ENVIRONMENT=cec-${{ env.ENVIRONMENT }} + push: true + tags: ${{ env.REGISTRY }}/${{ env.PROJECT }}:${{ env.TAG }}-cec-${{ env.ENVIRONMENT }} + cache-from: type=gha + cache-to: type=gha,mode=max + deploy: needs: build runs-on: [self-hosted, azure] env: ENVIRONMENT: ${{ needs.build.outputs.build-env }} steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: rtCamp/action-slack-notify@v2 env: MSG_MINIMAL: true @@ -90,16 +105,32 @@ jobs: --set image.tag=$TAG-$ENVIRONMENT \ --wait -i -f k8s/values-$ENVIRONMENT.yaml $PROJECT k8s/ - - name: Notify if success - if: ${{ success() }} + - name: Notify deploy uses: rtCamp/action-slack-notify@v2 env: MSG_MINIMAL: true SLACK_MESSAGE: "Successfully deployed ${{ env.PROJECT }} to ${{ env.ENVIRONMENT }}! :gopher_party:" + - name: Deploy new prod + if: github.ref == 'refs/heads/main' + run: |- + helm upgrade \ + --kube-context cec-$ENVIRONMENT-cluster-1 \ + --set image.registry=$REGISTRY \ + --set image.name=$PROJECT \ + --set image.tag=$TAG-cec-$ENVIRONMENT \ + --wait -i -f k8s/values-cec-$ENVIRONMENT.yaml $PROJECT k8s/ + + - name: Notify deploy new + if: github.ref == 'refs/heads/main' + uses: rtCamp/action-slack-notify@v2 + env: + MSG_MINIMAL: true + SLACK_MESSAGE: "Successfully deployed ${{ env.PROJECT }} to cec-${{ env.ENVIRONMENT }}! :gopher_party:" + - name: Notify if failure if: ${{ failure() }} uses: rtCamp/action-slack-notify@v2 env: SLACK_COLOR: ${{ job.status }} - SLACK_MESSAGE: "Something failed! :this-is-fine:" + SLACK_MESSAGE: "Failed to deploy ${{ env.PROJECT }} to ${{ env.ENVIRONMENT }}! :this-is-fine:" diff --git a/k8s/values-cec-prd.yaml b/k8s/values-cec-prd.yaml new file mode 100644 index 0000000..c2c8e18 --- /dev/null +++ b/k8s/values-cec-prd.yaml @@ -0,0 +1,12 @@ +ingress: + hostname: ota-admin.cec-prd.fiskerinc.com + +resources: + requests: + cpu: 100m + memory: 128Mi + limits: + cpu: 250m + memory: 256Mi + +replicas: 3 diff --git a/package.json b/package.json index 5a7d5ed..6117d3b 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "build:dev": "env-cmd -f .env.dev react-scripts build", "build:stg": "env-cmd -f .env.stg react-scripts build", "build:prd": "env-cmd -f .env.prd react-scripts build", + "build:cec-prd": "env-cmd -f .env.cec-prd react-scripts build", "build:local": "env-cmd -f .env.local react-scripts build", "test": "env-cmd -f .env.local react-scripts test --no-cache", "test:debug": "react-scripts --inspect-brk test --runInBand --no-cache", @@ -78,4 +79,4 @@ "lcov" ] } -} +} \ No newline at end of file