From 8c947b792f1f619d5f0930ecdfe47cdfde6e44b8 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv Date: Thu, 4 Jan 2024 13:25:11 +0400 Subject: [PATCH 1/4] refactor: To separate docker and k8s notification --- .github/workflows/production.yml | 65 +++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 33a790f8336..5c580680033 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -52,7 +52,7 @@ jobs: - run: npm run test - run: npm run build - run: echo $GIT_TAG_NAME > public/version.txt - + - name: Remove Storybook uses: JesseTG/rm@v1.0.2 with: @@ -70,9 +70,37 @@ jobs: accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: pages deploy public --project-name=deriv-com-pages --branch=main + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: build + path: packages/core/dist + retention-days: 1 + - name: Cloudflare production link ✨ run: echo "New website - http://cf-pages-deriv-com.deriv.com" + - name: Slack Notification 📣 + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: workflow,repo + if_mention: failure,cancelled + custom_payload: | + { + attachments: [{ + color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning', + text: `Release for *Deriv.com* with version *$GIT_TAG_NAME*` + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + if: always() + + build_and_publish_to_docker_k8s: + runs-on: Runner_8cores_Deriv-app + environment: production + steps: - name: Building docker image 🐳 run: docker build -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME . @@ -90,11 +118,11 @@ jobs: - name: Deploy 🚀 env: - KUBE_SERVER: ${{ secrets.KUBE_SERVER }} - SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - CA_CRT: ${{ secrets.CA_CRT }} - NAMESPACE: deriv-com-production - DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} + KUBE_SERVER: ${{ secrets.KUBE_SERVER }} + SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} + CA_CRT: ${{ secrets.CA_CRT }} + NAMESPACE: deriv-com-production + DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} run: | git clone https://github.com/binary-com/devops-ci-scripts cd devops-ci-scripts/k8s-build_tools @@ -102,19 +130,20 @@ jobs: export CA="ca.crt" ./release.sh deriv-com ${{ github.ref_name }} - - name: Slack Notification 📣 + - name: Send Slack Notification on Docker Publish and Kubernetes Deployment Failure uses: 8398a7/action-slack@v3 + with: - status: ${{ job.status }} - fields: workflow,repo - if_mention: failure,cancelled - custom_payload: | - { - attachments: [{ - color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning', - text: `Release for *Deriv.com* with version *$GIT_TAG_NAME*` - }] - } + status: ${{ job.status }} + fields: workflow,repo + if_mention: failure,cancelled + custom_payload: | + { + attachments: [{ + color: '${{ job.status }}' === 'failure' ? 'danger' : 'warning', + text: `Release for *Deriv.com* with version *$GIT_TAG_NAME* has failed` + }] + } env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} if: always() From 5a7f4c01f869243de74af9a1b8537a4dbdee524c Mon Sep 17 00:00:00 2001 From: yaswanth-deriv Date: Thu, 4 Jan 2024 13:28:54 +0400 Subject: [PATCH 2/4] refactor: To remove extra spaces --- .github/workflows/production.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 5c580680033..39099c8a402 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -118,11 +118,11 @@ jobs: - name: Deploy 🚀 env: - KUBE_SERVER: ${{ secrets.KUBE_SERVER }} - SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - CA_CRT: ${{ secrets.CA_CRT }} - NAMESPACE: deriv-com-production - DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} + KUBE_SERVER: ${{ secrets.KUBE_SERVER }} + SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} + CA_CRT: ${{ secrets.CA_CRT }} + NAMESPACE: deriv-com-production + DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} run: | git clone https://github.com/binary-com/devops-ci-scripts cd devops-ci-scripts/k8s-build_tools @@ -132,12 +132,11 @@ jobs: - name: Send Slack Notification on Docker Publish and Kubernetes Deployment Failure uses: 8398a7/action-slack@v3 - with: - status: ${{ job.status }} - fields: workflow,repo - if_mention: failure,cancelled - custom_payload: | + status: ${{ job.status }} + fields: workflow,repo + if_mention: failure,cancelled + custom_payload: | { attachments: [{ color: '${{ job.status }}' === 'failure' ? 'danger' : 'warning', @@ -145,5 +144,5 @@ jobs: }] } env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} if: always() From 96df3077ceeff281df782dcd07e78a1ec1d2a5f9 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv Date: Thu, 4 Jan 2024 13:32:54 +0400 Subject: [PATCH 3/4] refactor: To remove extra spaces --- .github/workflows/production.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 39099c8a402..13b58791ad0 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -70,13 +70,6 @@ jobs: accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: pages deploy public --project-name=deriv-com-pages --branch=main - - name: Upload Build Artifact - uses: actions/upload-artifact@v4 - with: - name: build - path: packages/core/dist - retention-days: 1 - - name: Cloudflare production link ✨ run: echo "New website - http://cf-pages-deriv-com.deriv.com" From d223ada0a97845c8ff5ac09cbb0f55b7df162d26 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv Date: Tue, 9 Jan 2024 15:31:24 +0400 Subject: [PATCH 4/4] refactor: added not success condition in docker slack --- .github/workflows/production.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 13b58791ad0..abc7c2e6d19 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -110,6 +110,7 @@ jobs: docker push ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME - name: Deploy 🚀 + id: build_and_push_docker_image env: KUBE_SERVER: ${{ secrets.KUBE_SERVER }} SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} @@ -138,4 +139,4 @@ jobs: } env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - if: always() + if: ${{ steps.build_and_push_docker_image.outcome != 'success' }}