forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add k8 backup and slack integration (binary-com#7591)
- Loading branch information
1 parent
6bdd753
commit d910de3
Showing
2 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,84 @@ jobs: | |
name: production | ||
path: sites/eu/public | ||
retention-days: 5 | ||
- 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_16cores | ||
environment: production | ||
needs: [release-production] | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/[email protected] | ||
- name: Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18.x' | ||
- name: Download Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: production | ||
path: sites/eu/public | ||
- name: Set version env variable | ||
run: echo "GIT_TAG_NAME=$(cat public/version.txt)" >> $GITHUB_ENV | ||
- name: Building docker image 🐳 | ||
run: docker build -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME . | ||
|
||
- name: Verify nginx image | ||
run: | | ||
set -e | ||
docker run --rm ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME nginx -t | ||
echo "docker image validated successfully" | ||
- name: Pushing Image to docker hub 🐳 | ||
run: | | ||
echo ${{ secrets.DOCKERHUB_PASSWORD }}| docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
docker push ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest | ||
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 }} | ||
CA_CRT: ${{ secrets.CA_CRT }} | ||
NAMESPACE: deriv-com-production-eu | ||
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} | ||
run: | | ||
git clone https://github.com/binary-com/devops-ci-scripts | ||
cd devops-ci-scripts/k8s-build_tools | ||
echo "${{ env.CA_CRT }}" | base64 --decode > ca.crt | ||
export CA="ca.crt" | ||
./release.sh deriv-com ${{ github.ref_name }} | ||
- 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 }}' === 'failure' ? 'danger' : 'warning', | ||
text: `Release for *Deriv.com* with version *$GIT_TAG_NAME* has failed` | ||
}] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} | ||
if: failure() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,84 @@ jobs: | |
name: production | ||
path: sites/row/public | ||
retention-days: 5 | ||
- 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_16cores | ||
environment: production | ||
needs: [release-production] | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/[email protected] | ||
- name: Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18.x' | ||
- name: Download Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: production | ||
path: sites/row/public | ||
- name: Set version env variable | ||
run: echo "GIT_TAG_NAME=$(cat public/version.txt)" >> $GITHUB_ENV | ||
- name: Building docker image 🐳 | ||
run: docker build -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME . | ||
|
||
- name: Verify nginx image | ||
run: | | ||
set -e | ||
docker run --rm ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME nginx -t | ||
echo "docker image validated successfully" | ||
- name: Pushing Image to docker hub 🐳 | ||
run: | | ||
echo ${{ secrets.DOCKERHUB_PASSWORD }}| docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
docker push ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest | ||
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 }} | ||
CA_CRT: ${{ secrets.CA_CRT }} | ||
NAMESPACE: deriv-com-production-row | ||
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} | ||
run: | | ||
git clone https://github.com/binary-com/devops-ci-scripts | ||
cd devops-ci-scripts/k8s-build_tools | ||
echo "${{ env.CA_CRT }}" | base64 --decode > ca.crt | ||
export CA="ca.crt" | ||
./release.sh deriv-com ${{ github.ref_name }} | ||
- 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 }}' === 'failure' ? 'danger' : 'warning', | ||
text: `Release for *Deriv.com* with version *$GIT_TAG_NAME* has failed` | ||
}] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} | ||
if: failure() |