Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit a149a13

Browse files
Merge pull request #275 from jim-deriv/Jim/feq-1090/separate-docker-and-kubernetes-notification
[FEQ] Jim/FEQ-1090/separate docker and kubernetes notification
2 parents c394743 + 16b9db8 commit a149a13

File tree

2 files changed

+57
-40
lines changed

2 files changed

+57
-40
lines changed
Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,20 @@
11
name: notify_slack
2-
description: Send Slack notifications
2+
description: Send Slack notification
33
inputs:
44
SLACK_WEBHOOK_URL:
55
description: Slack webhook URL
66
required: true
7-
STATUS:
8-
description: Job status
7+
MESSAGE:
8+
description: 'Status message'
99
required: true
10-
RELEASE_TYPE:
11-
description: Release type
12-
required: true
13-
VERSION:
14-
description: Version
15-
required: true
16-
default: N/A
1710
runs:
1811
using: composite
1912
steps:
20-
- name: Send Slack Notification on Success
21-
if: ${{ inputs.STATUS == 'success' }}
13+
- name: Send Slack Notification
2214
run: |-
2315
curl -X POST -H 'Content-type: application/json' \
2416
--data '{
25-
"text": "'"${{ inputs.RELEASE_TYPE }}"' Release succeeded for api.deriv.com with version *'"${{ inputs.VERSION }}"'*"
17+
"text": "${{ inputs.MESSAGE }}",
2618
}' \
2719
${{ inputs.SLACK_WEBHOOK_URL }}
2820
shell: bash
29-
- name: Send Slack Notification on Failure
30-
if: ${{ inputs.STATUS == 'failure' }}
31-
run: |-
32-
curl -X POST -H 'Content-type: application/json' \
33-
--data '{
34-
"text": "'"${{ inputs.RELEASE_TYPE }}"' Release failed for api.deriv.com with version *'"${{ inputs.VERSION }}"'*"
35-
}' \
36-
${{ inputs.SLACK_WEBHOOK_URL }}
37-
shell: bash

.github/workflows/release_production.yml

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
push:
44
tags:
55
- production_v*
6+
env:
7+
RELEASE_TYPE: Production
68
jobs:
79
build_and_publish:
810
name: Builds and Publishes to Cloudflare Pages Production
@@ -25,7 +27,7 @@ jobs:
2527
uses: ./.github/actions/versioning
2628
with:
2729
RELEASE_TAG: ${{ github.ref_name }}
28-
RELEASE_TYPE: production
30+
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
2931
- name: Extract version
3032
id: extract_version
3133
run: echo "RELEASE_VERSION=$(cat build/version)" >> $GITHUB_OUTPUT
@@ -34,7 +36,52 @@ jobs:
3436
with:
3537
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
3638
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
39+
- name: Upload Build Artifact
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: build
43+
path: .
44+
retention-days: 1
45+
46+
send_slack_notification:
47+
name: Send Slack Notification
48+
environment: Production
49+
runs-on: ubuntu-latest
50+
if: always()
51+
needs: [build_and_publish]
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
- name: Conclusion
56+
uses: technote-space/workflow-conclusion-action@v3
57+
- name: Create Slack Message
58+
id: create_slack_message
59+
run: |
60+
if [ "${{ env.WORKFLOW_CONCLUSION }}" == "success" ]; then
61+
echo "MESSAGE=${{ env.RELEASE_TYPE }} Release succeeded for api.deriv.com with version *${{ needs.build_and_publish.outputs.RELEASE_VERSION }}*" >> $GITHUB_ENV
62+
elif ["${{ env.WORKFLOW_CONCLUSION }}" == "failure"]; then
63+
echo "MESSAGE=${{ env.RELEASE_TYPE }} Release failed for api.deriv.com with version *${{ needs.build_and_publish.outputs.RELEASE_VERSION }}*" >> $GITHUB_ENV
64+
else
65+
echo "MESSAGE=Unkown outcome" >> $GITHUB_ENV
66+
fi
67+
- name: Send Slack Notification
68+
uses: ./.github/actions/notify_slack
69+
with:
70+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
71+
MESSAGE: ${{ steps.create_slack_message.outputs.MESSAGE }}
72+
73+
build_and_publish_to_docker_k8s:
74+
name: Builds and Publishes image to Docker and Kubernetes
75+
runs-on: ubuntu-latest
76+
environment: Production
77+
needs: [build_and_publish]
78+
steps:
79+
- name: Download Build Artifact
80+
uses: actions/download-artifact@v4
81+
with:
82+
name: build
3783
- name: Publish to Docker
84+
id: publish_to_docker
3885
uses: ./.github/actions/publish_to_docker
3986
with:
4087
DOCKER_LATEST_IMAGE_TAG: 'latest'
@@ -43,6 +90,7 @@ jobs:
4390
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
4491
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
4592
- name: Deploy to Kubernetes
93+
id: deploy_to_kubernetes
4694
uses: ./.github/actions/deploy_to_kubernetes
4795
with:
4896
K8S_VERSION: ${{ github.ref_name }}
@@ -51,23 +99,9 @@ jobs:
5199
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
52100
KUBE_SERVER: ${{ secrets.KUBE_SERVER }}
53101
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
54-
55-
send_slack_notification:
56-
name: Send Slack Notification
57-
environment: Production
58-
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
59-
if: always()
60-
needs:
61-
- build_and_publish
62-
steps:
63-
- name: Checkout
64-
uses: actions/checkout@v4
65-
- name: Conclusion
66-
uses: technote-space/workflow-conclusion-action@v3
67102
- name: Send Slack Notification
103+
if: ${{ steps.publish_to_docker.outcome != 'success' || steps.deploy_to_kubernetes.outcome != 'success' }}
68104
uses: ./.github/actions/notify_slack
69105
with:
70-
RELEASE_TYPE: Production
71-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
72-
STATUS: ${{ env.WORKFLOW_CONCLUSION }}
73-
version: ${{ needs.build_and_publish.outputs.RELEASE_VERSION}}
106+
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
107+
MESSAGE: "'${{ env.RELEASE_TYPE }}' Docker Publish and Kubernetes Deployment for api.deriv.com with version *'${{ needs.build_and_publish.outputs.RELEASE_VERSION }}'* has Failed *"

0 commit comments

Comments
 (0)