diff --git a/.github/actions/deploy_to_kubernetes/action.yml b/.github/actions/deploy_to_kubernetes/action.yml index c7f904348..145ff53d1 100644 --- a/.github/actions/deploy_to_kubernetes/action.yml +++ b/.github/actions/deploy_to_kubernetes/action.yml @@ -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 diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml index e8e12f0ec..ae0e64571 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -11,10 +11,8 @@ runs: using: composite steps: - name: Send Slack Notification - run: |- - curl -X POST -H 'Content-type: application/json' \ - --data '{ - "text": "${{ inputs.MESSAGE }}", - }' \ - ${{ inputs.SLACK_WEBHOOK_URL }} - shell: bash + uses: 'deriv-com/shared-actions/.github/actions/send_slack_notification@master' + with: + SLACK_WEBHOOK_URL: ${{ inputs.SLACK_WEBHOOK_URL }} + MESSAGE: ${{ inputs.MESSAGE }} + diff --git a/.github/actions/publish_to_docker/action.yml b/.github/actions/publish_to_docker/action.yml index 5c0c4f5c7..3875c0c95 100644 --- a/.github/actions/publish_to_docker/action.yml +++ b/.github/actions/publish_to_docker/action.yml @@ -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 diff --git a/.github/actions/versioning/action.yml b/.github/actions/versioning/action.yml index 405d11725..2993d55cc 100644 --- a/.github/actions/versioning/action.yml +++ b/.github/actions/versioning/action.yml @@ -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 diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 6ba9df4bc..3bd33d8e8 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -57,10 +57,10 @@ 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