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

Commit

Permalink
chore: seperate docker and kubernetes slack notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-deriv committed Dec 20, 2023
1 parent 96a8512 commit 2496567
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/actions/deploy_to_kubernetes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ runs:
echo ${{ inputs.CA_CRT }} | base64 --decode > ca.crt
export CA="ca.crt"
./release.sh ${APP_NAME} ${{ inputs.K8S_VERSION }}
continue-on-error: true
shell: bash
13 changes: 13 additions & 0 deletions .github/actions/notify_slack/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
description: Version
required: true
default: N/A
DOCKER_AND_KUBERNETES_STATUS:
description: Docker and Kubernetes publish and deployment status
required: true
default: N/A
runs:
using: composite
steps:
Expand All @@ -35,3 +39,12 @@ runs:
}' \
${{ inputs.SLACK_WEBHOOK_URL }}
shell: bash
- name: Send Slack Notification For Docker and Kubernetes Run Status on Failure
if: ${{ inputs.DOCKER_AND_KUBERNETES_STATUS == 'failure' }}
run: |-
curl -X POST -H 'Content-type: application/json' \
--data '{
"text": "'"${{ inputs.RELEASE_TYPE }}"' Docker Publish and Kubernetes Deployment for api.deriv.com with version *'"${{ inputs.VERSION }}"'* has Failed *
}' \
${{ inputs.SLACK_WEBHOOK_URL }}
shell: bash
1 change: 1 addition & 0 deletions .github/actions/publish_to_docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ runs:
echo ${{ inputs.DOCKERHUB_PASSWORD }} | docker login -u ${{ inputs.DOCKERHUB_USERNAME }} --password-stdin
docker push ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_IMAGE_TAG }}
docker push ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_LATEST_IMAGE_TAG }}
continue-on-error: true
shell: bash
21 changes: 18 additions & 3 deletions .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
outputs:
RELEASE_VERSION: ${{ steps.extract_version.outputs.RELEASE_VERSION }}
DOCKER_AND_KUBERNETES_STATUS: ${{ steps.check_docker_and_kubernetes_status.outputs.DOCKER_AND_KUBERNETES_STATUS }}
CLOUDFLARE_PAGES_DEPLOYMENT_STATUS: ${{ steps.check_cloudflare_pages_production_status.outputs.CLOUDFLARE_PAGES_DEPLOYMENT_STATUS }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -30,11 +32,17 @@ jobs:
id: extract_version
run: echo "RELEASE_VERSION=$(cat build/version)" >> $GITHUB_OUTPUT
- name: Publish to Cloudflare Pages Production
id: publish_to_pages_production
uses: ./.github/actions/publish_to_pages_production
with:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Check Cloudflare Pages Deployment Status
id: check_cloudflare_pages_production_status
run: |
echo "CLOUDFLARE_PAGES_DEPLOYMENT_STATUS=${{ steps.publish_to_pages_production.outcome }}" >> $GITHUB_OUTPUT
- name: Publish to Docker
id: publish_to_docker
uses: ./.github/actions/publish_to_docker
with:
DOCKER_LATEST_IMAGE_TAG: 'latest'
Expand All @@ -43,6 +51,7 @@ jobs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Deploy to Kubernetes
id: deploy_to_kubernetes
uses: ./.github/actions/deploy_to_kubernetes
with:
K8S_VERSION: ${{ github.ref_name }}
Expand All @@ -51,6 +60,13 @@ jobs:
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
KUBE_SERVER: ${{ secrets.KUBE_SERVER }}
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
- name: Check Docker and Kubernetes Status
id: check_docker_and_kubernetes_status
if: steps.publish_to_docker.outcome != 'success' || steps.deploy_to_kubernetes.outcome != 'success'
run: |
echo "DOCKER_AND_KUBERNETES_STATUS=failure" >> $GITHUB_OUTPUT
exit 1
send_slack_notification:
name: Send Slack Notification
Expand All @@ -62,12 +78,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Conclusion
uses: technote-space/workflow-conclusion-action@v3
- name: Send Slack Notification
uses: ./.github/actions/notify_slack
with:
RELEASE_TYPE: Production
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
STATUS: ${{ env.WORKFLOW_CONCLUSION }}
STATUS: ${{ needs.build_and_publish.outputs.CLOUDFLARE_PAGES_DEPLOYMENT_STATUS }}
version: ${{ needs.build_and_publish.outputs.RELEASE_VERSION}}
DOCKER_AND_KUBERNETES_STATUS: ${{ needs.build_and_publish.outputs.DOCKER_AND_KUBERNETES_STATUS }}
33 changes: 33 additions & 0 deletions .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
name: Builds and Publishes to Cloudflare Pages Staging
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
environment: Staging
outputs:
RELEASE_VERSION: ${{ steps.versioning.outputs.RELEASE_VERSION }}
DOCKER_AND_KUBERNETES_STATUS: ${{ steps.check_docker_and_kubernetes_status.outputs.DOCKER_AND_KUBERNETES_STATUS }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -26,12 +29,16 @@ jobs:
with:
RELEASE_TAG: ${{ github.sha }}
RELEASE_TYPE: staging
- name: Extract version
id: extract_version
run: echo "RELEASE_VERSION=$(cat build/version)" >> $GITHUB_OUTPUT
- name: Publish to Cloudflare Pages Staging
uses: ./.github/actions/publish_to_pages_staging
with:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Publish to Docker
id: publish_to_docker
uses: ./.github/actions/publish_to_docker
with:
DOCKER_LATEST_IMAGE_TAG: 'latest-staging'
Expand All @@ -40,6 +47,7 @@ jobs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Deploy to Kubernetes
id: deploy_to_kubernetes
uses: ./.github/actions/deploy_to_kubernetes
with:
K8S_VERSION: ${{ github.ref_name }}
Expand All @@ -48,3 +56,28 @@ jobs:
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
KUBE_SERVER: ${{ secrets.KUBE_SERVER }}
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
- name: Check Docker and Kubernetes Status
id: check_docker_and_kubernetes_status
if: steps.publish_to_docker.outcome != 'success' || steps.deploy_to_kubernetes.outcome != 'success'
run: |
echo "DOCKER_AND_KUBERNETES_STATUS=failure" >> $GITHUB_OUTPUT
exit 1
send_slack_notification:
name: Send Slack Notification
environment: Staging
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
if: always()
needs:
- build_and_publish
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Send Slack Notification
uses: ./.github/actions/notify_slack
with:
RELEASE_TYPE: Staging
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
STATUS: 'N/A'
version: ${{ needs.build_and_publish.outputs.RELEASE_VERSION}}
DOCKER_AND_KUBERNETES_STATUS: ${{ needs.build_and_publish.outputs.DOCKER_AND_KUBERNETES_STATUS }}

0 comments on commit 2496567

Please sign in to comment.