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

Ako/feq 701/setup GitHub workflows #17

21 changes: 21 additions & 0 deletions .github/actions/publish_to_pages_production/action.yml
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: |
npm i [email protected]
npx wrangler pages deploy dist/ --project-name=deriv-smarttrader --branch=main
echo "New website - http://dsmarttrader.deriv.com"
ali-hosseini-deriv marked this conversation as resolved.
Show resolved Hide resolved
shell: bash
21 changes: 21 additions & 0 deletions .github/actions/publish_to_pages_staging/action.yml
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: |
npm i [email protected]
npx wrangler pages deploy dist/ --project-name=deriv-smarttrader --branch=staging
echo "New staging website - http://staging-dsmarttrader.deriv.com"
ali-hosseini-deriv marked this conversation as resolved.
Show resolved Hide resolved
shell: bash
39 changes: 39 additions & 0 deletions .github/actions/send_slack_notifications/action.yml
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
44 changes: 44 additions & 0 deletions .github/workflows/release-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: SmartTrader Production Workflow
on:
push:
tags:
- production_*
jobs:
build_test_and_publish:
name: Build and Test
runs-on: ubuntu-latest
steps:
# checkout the repository content to github runner
- name: Checkout
uses: actions/checkout@v4
# setup nodejs environment
- name: Setup Node.js environment
uses: ./.github/actions/setup_node
# cache the dependencies to speed up the build and then install dependencies
- name: Cache dependencies
uses: ./.github/actions/npm_install_from_cache
# build the react app
- name: Build
run: npm run build
# run tests
- name: Publish to Cloudflare Staging
uses: ./.github/actions/publish_to_cloudflare_production

send_slack_notification:
name: Send Slack notification
runs-on: Runner_16cores_Deriv-app
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
26 changes: 26 additions & 0 deletions .github/workflows/release-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: SmartTrader Staging Workflow

on:
push:
branches:
- master
jobs:
build_and_test:
name: Build and Test
runs-on: ubuntu-latest
steps:
# checkout the repository content to github runner
- name: Checkout
uses: actions/checkout@v4
# setup nodejs environment
- name: Setup Node.js environment
uses: ./.github/actions/setup_node
# cache the dependencies to speed up the build and then install dependencies
- name: Cache dependencies
uses: ./.github/actions/npm_install_from_cache
# build the react app
- name: Build
run: npm run build
matin-deriv marked this conversation as resolved.
Show resolved Hide resolved
# run tests
ali-hosseini-deriv marked this conversation as resolved.
Show resolved Hide resolved
ali-hosseini-deriv marked this conversation as resolved.
Show resolved Hide resolved
- name: Publish to Cloudflare Staging
uses: ./.github/actions/publish_to_cloudflare_staging