Skip to content

Commit

Permalink
Merge pull request #11 from deriv-com/sandeep/fix-gh-actions
Browse files Browse the repository at this point in the history
chore: updated gh actions
  • Loading branch information
sandeep-deriv authored Apr 9, 2024
2 parents 6a656bf + 400e2a0 commit de40eaf
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 45 deletions.
22 changes: 11 additions & 11 deletions .github/actions/deploy_to_kubernetes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ inputs:
runs:
using: composite
steps:
- name: Setup Environment variables
run: |
echo "NAMESPACE=${{ inputs.K8S_NAMESPACE }}" >> "$GITHUB_ENV"
echo "KUBE_SERVER=${{ inputs.KUBE_SERVER }}" >> "$GITHUB_ENV"
echo "SERVICEACCOUNT_TOKEN=${{ inputs.SERVICEACCOUNT_TOKEN }}" >> "$GITHUB_ENV"
echo "DOCKERHUB_ORGANISATION=${{ inputs.DOCKERHUB_ORGANISATION }}" >> "$GITHUB_ENV"
echo "CA_CRT=${{ inputs.CA_CRT }}" >> "$GITHUB_ENV"
echo "APP_NAME=deriv-com-api" >> "$GITHUB_ENV"
shell: bash
- name: Deploying to k8s cluster for service ${{ inputs.K8S_NAMESPACE }} 🚀
env:
K8S_VERSION: ${{ inputs.K8S_VERSION }}
NAMESPACE: ${{ inputs.K8S_NAMESPACE }}
KUBE_SERVER: ${{ inputs.KUBE_SERVER }}
SERVICEACCOUNT_TOKEN: ${{ inputs.SERVICEACCOUNT_TOKEN }}
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
CA_CRT: ${{ inputs.CA_CRT }}
APP_NAME: deriv-com-api

run: |
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo ${{ inputs.CA_CRT }} | base64 --decode > ca.crt
echo $CA_CRT | base64 --decode > ca.crt
export CA="ca.crt"
./release.sh ${APP_NAME} ${{ inputs.K8S_VERSION }}
./release.sh ${APP_NAME} $K8S_VERSION
shell: bash
20 changes: 0 additions & 20 deletions .github/actions/notify_slack/action.yml

This file was deleted.

25 changes: 20 additions & 5 deletions .github/actions/publish_to_docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,33 @@ runs:
using: composite
steps:
- name: Building docker image 🐳
env:
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
DOCKER_IMAGE_TAG: ${{ inputs.DOCKER_IMAGE_TAG }}
DOCKER_LATEST_IMAGE_TAG: ${{ inputs.DOCKER_LATEST_IMAGE_TAG }}
run: |
docker build -t ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_IMAGE_TAG }} -t ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_LATEST_IMAGE_TAG }} .
docker build -t $DOCKERHUB_ORGANISATION/deriv-com-api:$DOCKER_IMAGE_TAG -t $DOCKERHUB_ORGANISATION/deriv-com-api:$DOCKER_LATEST_IMAGE_TAG .
shell: bash

- name: Verify nginx image
env:
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
DOCKER_LATEST_IMAGE_TAG: ${{ inputs.DOCKER_LATEST_IMAGE_TAG }}
run: |
set -e
docker run --rm ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_LATEST_IMAGE_TAG }} nginx -t
docker run --rm $DOCKERHUB_ORGANISATION/deriv-com-api:$DOCKER_LATEST_IMAGE_TAG nginx -t
echo "docker image validated successfully"
shell: bash

- name: Pushing Image to docker hub 🐳
env:
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
DOCKER_IMAGE_TAG: ${{ inputs.DOCKER_IMAGE_TAG }}
DOCKER_LATEST_IMAGE_TAG: ${{ inputs.DOCKER_LATEST_IMAGE_TAG }}
DOCKERHUB_PASSWORD: ${{ inputs.DOCKERHUB_PASSWORD }}
DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }}
run: |
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 }}
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
docker push $DOCKERHUB_ORGANISATION/deriv-com-api:$DOCKER_IMAGE_TAG
docker push $DOCKERHUB_ORGANISATION/deriv-com-api:$DOCKER_LATEST_IMAGE_TAG
shell: bash
5 changes: 4 additions & 1 deletion .github/actions/versioning/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ runs:
using: composite
steps:
- name: Tag build
run: echo "${{ inputs.RELEASE_TYPE }}--GITHUB_REF:${{ inputs.RELEASE_TAG }}--DATE:$(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version.txt
env:
RELEASE_TYPE: ${{ inputs.RELEASE_TYPE }}
RELEASE_TAG: ${{ inputs.RELEASE_TAG }}
run: echo "$RELEASE_TYPE--GITHUB_REF:$RELEASE_TAG--DATE:$(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version.txt
shell: bash
14 changes: 7 additions & 7 deletions .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ jobs:
- name: Create Slack Message
id: create_slack_message
run: |
if [ "${{ env.WORKFLOW_CONCLUSION }}" == "success" ]; then
echo "MESSAGE=${{ env.RELEASE_TYPE }} Release succeeded for api.deriv.com with version *${{ needs.build_and_publish.outputs.RELEASE_VERSION }}*" >> $GITHUB_OUTPUT
if [ "$WORKFLOW_CONCLUSION" == "success" ]; then
echo "MESSAGE=$RELEASE_TYPE }} Release succeeded for api.deriv.com with version *${{ needs.build_and_publish.outputs.RELEASE_VERSION }}*" >> $GITHUB_OUTPUT
else
echo "MESSAGE=${{ env.RELEASE_TYPE }} Release failed for api.deriv.com with version *${{ needs.build_and_publish.outputs.RELEASE_VERSION }}*" >> $GITHUB_OUTPUT
echo "MESSAGE=$RELEASE_TYPE }} Release failed for api.deriv.com with version *${{ needs.build_and_publish.outputs.RELEASE_VERSION }}*" >> $GITHUB_OUTPUT
fi
- name: Send Slack Notification
uses: ./.github/actions/notify_slack
uses: 'deriv-com/shared-actions/.github/actions/send_slack_notification@master'
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: ${{ steps.create_slack_message.outputs.MESSAGE }}
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
- name: Send Slack Notification
if: ${{ steps.publish_to_docker.outcome != 'success' || steps.deploy_to_kubernetes.outcome != 'success' }}
uses: ./.github/actions/notify_slack
uses: 'deriv-com/shared-actions/.github/actions/send_slack_notification@master'
with:
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
MESSAGE: "'${{ env.RELEASE_TYPE }}' Docker Publish and Kubernetes Deployment for api.deriv.com with version *'${{ needs.build_and_publish.outputs.RELEASE_VERSION }}'* has Failed *"
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: "$RELEASE_TYPE Docker Publish and Kubernetes Deployment for api.deriv.com with version *'${{ needs.build_and_publish.outputs.RELEASE_VERSION }}'* has Failed *"
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"editor.codeActionsOnSave": { "source.fixAll.eslint": true },
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}

0 comments on commit de40eaf

Please sign in to comment.