-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from yaswanth-deriv/yaswanth/FEQ-1233_Websock…
…ets-CircleCi-Migration-to-github-actions [FEQ]Yaswanth/FEQ-1233/Migration from circle-ci to github work actions
- Loading branch information
Showing
11 changed files
with
313 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: build_and_push_docker_image_and_k8s | ||
description: Build docker image and push to docker hub and K8S | ||
inputs: | ||
DOCKERHUB_ORGANISATION: | ||
description: "Dockerhub Organisation" | ||
required: true | ||
DOCKERHUB_USERNAME: | ||
description: "Dockerhub Username" | ||
required: true | ||
DOCKERHUB_PASSWORD: | ||
description: "Dockerhub Password" | ||
required: true | ||
K8S_NAMESPACE: | ||
description: "K8S namespace" | ||
required: true | ||
K8S_SERVICE: | ||
description: "K8S service" | ||
required: true | ||
KUBE_SERVER: | ||
description: "K8S server" | ||
required: true | ||
SERVICEACCOUNT_TOKEN: | ||
description: "K8S service account token" | ||
required: true | ||
CA_CRT: | ||
description: "K8S CA_CRT" | ||
required: true | ||
APP_VERSION: | ||
description: "App version" | ||
required: true | ||
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=binary-static-developers" >> "$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 }} . | ||
shell: bash | ||
- name: Verify nginx image | ||
run: | | ||
set -e | ||
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 🐳 | ||
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 }} | ||
shell: bash | ||
- name: Deploy 🚀 | ||
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 }} | ||
shell: bash |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: build | ||
description: "Build Jekyll site" | ||
runs: | ||
using: composite | ||
steps: | ||
- restore_cache: | ||
name: "Build cache restore" | ||
keys: | ||
- _site-v1-{{ .Revision }} | ||
- _site-v1- | ||
- build_site: | ||
name: Building Jekyll site | ||
run: | | ||
bundle exec jekyll build --incremental | ||
- save_cache: | ||
name: Build cache save | ||
key: _site-v1-{{ .Revision }} | ||
with: | ||
paths: | ||
- _site |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: bundle_install | ||
description: Bundle Install | ||
runs: | ||
using: composite | ||
steps: | ||
- restore_cache: | ||
name: Bundle modules cache restore | ||
keys: | ||
- bundle-v1-{{ checksum "Gemfile" }} | ||
- bundle-v1- | ||
- bundle_install: | ||
name: Bundle install | ||
run: | | ||
bundle install --path ./modules | ||
- save_cache: | ||
name: Bundle modules cache save | ||
key: bundle-v1-{{ checksum "Gemfile" }} | ||
with: | ||
paths: | ||
- "modules" |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: invalidate_npm_cache | ||
description: Invalidate the Master NPM cache | ||
runs: | ||
using: composite | ||
steps: | ||
- name: save_cache | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: ./node_modules | ||
key: v1-deps-{{ checksum "Gemfile" }} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: publish_to_pages_production | ||
description: Publish to cloudflare pages (production) | ||
inputs: | ||
CLOUDFLARE_ACCOUNT_ID: | ||
description: 'Cloudflare account id' | ||
required: true | ||
CLOUDFLARE_API_TOKEN: | ||
description: 'Cloudflare token' | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Publish to cloudflare pages (production) | ||
env: | ||
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} | ||
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} | ||
run: | | ||
cd _site | ||
npx wrangler pages publish . --project-name=websockets-pages --branch=main | ||
echo "New website - http://cf-pages-websockets.binary.com" | ||
shell: bash |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: publish_to_pages_staging | ||
description: Publish to cloudflare pages (staging) | ||
inputs: | ||
CLOUDFLARE_ACCOUNT_ID: | ||
description: 'Cloudflare account id' | ||
required: true | ||
CLOUDFLARE_API_TOKEN: | ||
description: 'Cloudflare token' | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Publish to cloudflare pages (staging) | ||
env: | ||
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} | ||
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} | ||
run: | | ||
cd _site | ||
npx wrangler pages publish . --project-name=websockets-pages --branch=staging | ||
echo "New staging website - http://staging.cf-pages-websockets.binary.com" | ||
shell: bash |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: send_slack_notifications | ||
description: Send Slack notifications | ||
inputs: | ||
SLACK_WEBHOOK_URL: | ||
description: 'Slack webhook URL' | ||
required: true | ||
status: | ||
description: 'Job status' | ||
required: true | ||
RELEASE_TYPE: | ||
description: 'Release type' | ||
required: true | ||
version: | ||
description: 'Version' | ||
required: true | ||
default: 'N/A' | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Send Slack Notification on Success | ||
|
||
if: inputs.status == 'success' | ||
run: | | ||
curl -X POST -H 'Content-type: application/json' \ | ||
--data '{ | ||
"text": "${{ inputs.RELEASE_TYPE }} Release succeeded for dsmarttrader.deriv.com with version ${{ inputs.VERSION }}" | ||
}' \ | ||
${{ inputs.SLACK_WEBHOOK_URL }} | ||
shell: bash | ||
|
||
- name: Send Slack Notification on Failure | ||
if: inputs.status == 'failure' | ||
run: | | ||
curl -X POST -H 'Content-type: application/json' \ | ||
--data '{ | ||
"text": "${{ inputs.RELEASE_TYPE }} Release failed for dsmarttrader.deriv.com with version ${{ inputs.VERSION }}" | ||
}' \ | ||
${{ inputs.SLACK_WEBHOOK_URL }} | ||
shell: bash |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: Setup Node | ||
description: Setup Node.js environment | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Use Node.js 18.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: versioning | ||
description: Versioning | ||
inputs: | ||
RELEASE_TYPE: | ||
description: Release Type | ||
required: false | ||
outputs: | ||
version: | ||
description: Version | ||
runs: | ||
using: composite | ||
steps: | ||
- run: | ||
name: Tag build | ||
run: echo "${GITHUB_REF#refs/heads/} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > _site/version | ||
shell: bash |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Websocket Production Workflow | ||
on: | ||
push: | ||
tags: | ||
- production_* | ||
jobs: | ||
build_test_and_publish: | ||
name: Build, Test and Publish to Production | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Bundle Install | ||
uses: ./.github/actions/bundle_install | ||
- name: Build Jekyll site | ||
uses: ./.github/actions/build | ||
- name: Versioning | ||
uses: ./.github/actions/versioning | ||
with: | ||
release_type: production | ||
- name: Publish to Cloudflare 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: Build Docker image and push to Docker hub and K8S | ||
uses: "./.github/actions/build_and_push_docker_image" | ||
with: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} | ||
K8S_NAMESPACE: "developers-binary-com-production" | ||
KUBE_SERVER: ${{ secrets.KUBE_SERVER }} | ||
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} | ||
CA_CRT: ${{ secrets.CA_CRT }} | ||
APP_VERSION: latest | ||
|
||
send_slack_notification: | ||
name: Send Slack notification | ||
runs-on: ubuntu-latest | ||
environment: Production | ||
if: always() | ||
needs: [build_test_and_publish] | ||
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: Production | ||
version: $GITHUB_REF_NAME |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Websocket Staging Workflow | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
build_test_and_publish: | ||
name: Build, Test and Publish to Staging | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Bundle Install | ||
uses: ./.github/actions/bundle_install | ||
- name: Build Jekyll site | ||
uses: ./.github/actions/build | ||
- name: Versioning | ||
uses: ./.github/actions/versioning | ||
with: | ||
release_type: staging | ||
- 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: Build Docker image and push to Docker hub and K8S | ||
uses: "./.github/actions/build_and_push_docker_image" | ||
with: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} | ||
K8S_NAMESPACE: "developers-binary-com-staging" | ||
KUBE_SERVER: ${{ secrets.KUBE_SERVER }} | ||
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} | ||
CA_CRT: ${{ secrets.CA_CRT }} | ||
APP_VERSION: latest-staging |