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

Commit

Permalink
Merge pull request #449 from sandeep-deriv/sandeep/fix-ghworkflow-1
Browse files Browse the repository at this point in the history
chore: added vars to docker workflow
  • Loading branch information
sandeep-deriv authored Apr 3, 2024
2 parents d068820 + 1e649bd commit e3cbd1e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 33 deletions.
48 changes: 32 additions & 16 deletions .github/actions/build_and_push_docker_image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,52 @@ 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-static-bot" >> "$GITHUB_ENV"
echo "APP_VERSION=${{ inputs.APP_VERSION }}" >> "$GITHUB_ENV"
shell: bash
- name: Build docker image 🐳
run: docker build -t ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${APP_VERSION} -t ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }} .
env:
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
APP_NAME: deriv-static-bot
APP_VERSION: ${{ inputs.APP_VERSION }}
GITHUB_REF_NAME: ${{ github.ref_name }}
run: docker build -t $DOCKERHUB_ORGANISATION/$APP_NAME:$APP_VERSION -t $DOCKERHUB_ORGANISATION/$APP_NAME:$GITHUB_REF_NAME .
shell: bash

- name: Verify nginx image
env:
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
APP_NAME: deriv-static-bot
GITHUB_REF_NAME: ${{ github.ref_name }}
run: |
set -e
docker run --rm ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }} nginx -t
docker run --rm $DOCKERHUB_ORGANISATION/$APP_NAME:$GITHUB_REF_NAME nginx -t
echo "docker image validated successfully"
shell: bash

- name: Pushing Image to docker hub 🐳
env:
DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }}
DOCKERHUB_PASSWORD: ${{ inputs.DOCKERHUB_PASSWORD }}
DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }}
APP_NAME: deriv-static-bot
APP_VERSION: ${{ inputs.APP_VERSION }}
GITHUB_REF_NAME: ${{ github.ref_name }}
run: |
echo ${{ inputs.DOCKERHUB_PASSWORD }}| docker login -u ${{ inputs.DOCKERHUB_USERNAME }} --password-stdin
docker push ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${APP_VERSION}
docker push ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }}
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
docker push $DOCKERHUB_ORGANISATION/$APP_NAME:$APP_VERSION
docker push $DOCKERHUB_ORGANISATION/$APP_NAME:$GITHUB_REF_NAME
shell: bash

- name: Deploy 🚀
env:
CA_CRT: ${{ inputs.CA_CRT }}
GITHUB_REF_NAME: ${{ github.ref_name }}
APP_NAME: deriv-static-bot
NAMESPACE: ${{ inputs.K8S_NAMESPACE }}
KUBE_SERVER: ${{ inputs.KUBE_SERVER }}
SERVICEACCOUNT_TOKEN: ${{ inputs.SERVICEACCOUNT_TOKEN }}
run: |
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo $CA_CRT | base64 --decode > ca.crt
export CA="ca.crt"
./release.sh ${APP_NAME} ${{ github.ref_name }}
./release.sh $APP_NAME $GITHUB_REF_NAME
shell: bash
34 changes: 17 additions & 17 deletions .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ jobs:
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
CA_CRT: ${{ secrets.CA_CRT }}
APP_VERSION: latest-staging
send_slack_notification:
if: always()
needs: [release_staging]
environment: Staging
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Conclusion
uses: technote-space/workflow-conclusion-action@v3
- name: Send Slack Notification
uses: "./.github/actions/send_slack_notifications"
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ env.WORKFLOW_CONCLUSION }}
release_type: Staging
version: 'latest-master'
# send_slack_notification:
# if: always()
# needs: [release_staging]
# environment: Staging
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Conclusion
# uses: technote-space/workflow-conclusion-action@v3
# - name: Send Slack Notification
# uses: "./.github/actions/send_slack_notifications"
# with:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# status: ${{ env.WORKFLOW_CONCLUSION }}
# release_type: Staging
# version: 'latest-master'

0 comments on commit e3cbd1e

Please sign in to comment.