Skip to content

Commit 94388cf

Browse files
Merge pull request #630 from ahmadtaimoor-deriv/f_gh_workflow-alert
[DTRA]/Ahmad/DTRA-1147/GH Workflow Alerts
2 parents ce3aaea + e492fa8 commit 94388cf

File tree

5 files changed

+64
-72
lines changed

5 files changed

+64
-72
lines changed

.github/actions/build/action.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
name: Build
2-
description: Build dist
2+
description: Build dist
33
inputs:
44
target:
5-
description: 'Target Environment'
5+
description: "Target Environment"
66
required: true
77
default: staging
88
runs:
99
using: composite
1010
steps:
11-
- name: Building dist for ${{ inputs.target }}
12-
run: node_modules/grunt/bin/grunt releaseci --${{ inputs.target }}
13-
shell: bash
11+
- name: Building dist for ${{ inputs.target }}
12+
env:
13+
TARGET_ENV: ${{ inputs.target }}
14+
run: node_modules/grunt/bin/grunt releaseci --$TARGET_ENV
15+
shell: bash

.github/actions/build_and_push_docker_image/action.yml

+27-16
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,47 @@ inputs:
3131
runs:
3232
using: composite
3333
steps:
34-
- name: Setup Environment variables
35-
run: |
36-
echo "NAMESPACE=${{ inputs.K8S_NAMESPACE }}" >> "$GITHUB_ENV"
37-
echo "KUBE_SERVER=${{ inputs.KUBE_SERVER }}" >> "$GITHUB_ENV"
38-
echo "SERVICEACCOUNT_TOKEN=${{ inputs.SERVICEACCOUNT_TOKEN }}" >> "$GITHUB_ENV"
39-
echo "DOCKERHUB_ORGANISATION=${{ inputs.DOCKERHUB_ORGANISATION }}" >> "$GITHUB_ENV"
40-
echo "CA_CRT=${{ inputs.CA_CRT }}" >> "$GITHUB_ENV"
41-
echo "APP_NAME=smarttrader-deriv-app" >> "$GITHUB_ENV"
42-
echo "APP_VERSION=${{ inputs.APP_VERSION }}" >> "$GITHUB_ENV"
43-
shell: bash
4434
- name: Build docker image 🐳
45-
run: docker build -t ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${APP_VERSION} -t ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }} .
35+
env:
36+
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
37+
APP_NAME: smarttrader-deriv-app
38+
APP_VERSION: ${{ inputs.APP_VERSION }}
39+
run: docker build -t $DOCKERHUB_ORGANISATION/$APP_NAME:$APP_VERSION -t $DOCKERHUB_ORGANISATION/$APP_NAME:${{ github.ref_name }} .
4640
shell: bash
4741
- name: Verify nginx image
42+
env:
43+
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
44+
APP_NAME: smarttrader-deriv-app
4845
run: |
4946
set -e
50-
docker run --rm ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }} nginx -t
47+
docker run --rm $DOCKERHUB_ORGANISATION/$APP_NAME:${{ github.ref_name }} nginx -t
5148
echo "docker image validated successfully"
5249
shell: bash
5350
- name: Pushing Image to docker hub 🐳
51+
env:
52+
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
53+
APP_NAME: smarttrader-deriv-app
54+
APP_VERSION: ${{ inputs.APP_VERSION }}
55+
DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }}
56+
DOCKERHUB_PASSWORD: ${{ inputs.DOCKERHUB_PASSWORD }}
5457
run: |
55-
echo ${{ inputs.DOCKERHUB_PASSWORD }}| docker login -u ${{ inputs.DOCKERHUB_USERNAME }} --password-stdin
56-
docker push ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${APP_VERSION}
57-
docker push ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }}
58+
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
59+
docker push $DOCKERHUB_ORGANISATION/$APP_NAME:$APP_VERSION
60+
docker push $DOCKERHUB_ORGANISATION/$APP_NAME:${{ github.ref_name }}
5861
shell: bash
5962
- name: Deploy 🚀
63+
env:
64+
NAMESPACE: ${{ inputs.K8S_NAMESPACE }}
65+
KUBE_SERVER: ${{ inputs.KUBE_SERVER }}
66+
SERVICEACCOUNT_TOKEN: ${{ inputs.SERVICEACCOUNT_TOKEN }}
67+
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
68+
CA_CRT: ${{ inputs.CA_CRT }}
69+
APP_NAME: smarttrader-deriv-app
70+
APP_VERSION: ${{ inputs.APP_VERSION }}
6071
run: |
6172
git clone https://github.com/binary-com/devops-ci-scripts
6273
cd devops-ci-scripts/k8s-build_tools
6374
echo $CA_CRT | base64 --decode > ca.crt
6475
export CA="ca.crt"
65-
./release.sh ${APP_NAME} ${{ github.ref_name }}
76+
./release.sh $APP_NAME ${{ github.ref_name }}
6677
shell: bash

.github/actions/notify_slack/action.yml

-40
This file was deleted.

.github/actions/versioning/action.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ name: versioning
22
description: Tag build
33
inputs:
44
target_branch:
5-
description: 'Target branch'
5+
description: "Target branch"
66
required: false
77
runs:
88
using: composite
99
steps:
10-
- name: Tag build
11-
run: echo "${{ inputs.target_branch }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > dist/version.txt
12-
shell: bash
10+
- name: Tag build
11+
env:
12+
TARGET_BRANCH: ${{ inputs.target_branch }}
13+
run: echo "$TARGET_BRANCH $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > dist/version.txt
14+
shell: bash

.github/workflows/release_production.yml

+24-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
build_and_test:
88
name: Build and Test
99
runs-on: ubuntu-latest
10+
env:
11+
RELEASE_TYPE: Production
1012
steps:
1113
- name: Checkout
1214
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
@@ -34,6 +36,8 @@ jobs:
3436
publish_cloudflare_production:
3537
name: Publish to Cloudflare Production
3638
runs-on: ubuntu-latest
39+
env:
40+
RELEASE_TYPE: Production
3741
needs: [build_and_test]
3842
steps:
3943
- name: Checkout
@@ -53,6 +57,7 @@ jobs:
5357
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
5458
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5559
- name: Build Docker image and push to Docker hub and K8S
60+
id: build_and_push_docker_image
5661
uses: "./.github/actions/build_and_push_docker_image"
5762
with:
5863
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -63,12 +68,19 @@ jobs:
6368
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
6469
CA_CRT: ${{ secrets.CA_CRT }}
6570
APP_VERSION: latest
66-
71+
- name: Send Slack Notification on Docker Publish and Kubernetes Deployment Failure
72+
if: ${{ steps.build_and_push_docker_image.outcome != 'success' }}
73+
uses: "deriv-com/shared-actions/.github/actions/send_slack_notification@master"
74+
with:
75+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
76+
MESSAGE: "$RELEASE_TYPE Docker Publish and Kubernetes Deployment for smarttrader.deriv.com with version ${{ needs.build_and_test.outputs.RELEASE_VERSION }} has Failed"
6777
notify_on_slack:
6878
name: Notify on Slack
6979
if: always()
7080
runs-on: ubuntu-latest
71-
81+
env:
82+
RELEASE_TYPE: Production
83+
APP_NAME: smarttrader-deriv-app
7284
needs: [publish_cloudflare_production, build_and_test]
7385
steps:
7486
- name: Checkout
@@ -79,7 +91,6 @@ jobs:
7991
node-version: 20
8092
- name: Conclusion
8193
uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5
82-
8394
- name: Download Artifacts
8495
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
8596
with:
@@ -88,10 +99,16 @@ jobs:
8899
- name: Grab Version Name
89100
id: extract_version
90101
run: echo "RELEASE_VERSION=$(cat dist/version.txt)" >> $GITHUB_ENV
102+
- name: Create Slack Message
103+
id: create_slack_message
104+
run: |
105+
if [ $WORKFLOW_CONCLUSION == "success" ]; then
106+
echo "MESSAGE=$RELEASE_TYPE Release succeeded for $APP_NAME with version ${{ needs.build_and_test.outputs.RELEASE_VERSION }}" >> $GITHUB_OUTPUT
107+
else
108+
echo "MESSAGE=$RELEASE_TYPE Release failed for $APP_NAME with version ${{ needs.build_and_test.outputs.RELEASE_VERSION }}" >> $GITHUB_OUTPUT
109+
fi
91110
- name: Send Slack Notification
92-
uses: "./.github/actions/notify_slack"
111+
uses: "deriv-com/shared-actions/.github/actions/send_slack_notification@master"
93112
with:
94113
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
95-
status: ${{ env.WORKFLOW_CONCLUSION }}
96-
release_type: Production
97-
version: ${{ steps.extract_version.outputs.RELEASE_VERSION }}
114+
MESSAGE: ${{ steps.create_slack_message.outputs.MESSAGE }}

0 commit comments

Comments
 (0)