Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ako/add GitHub actions #572

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Build
inputs:
target:
required: false
default: staging
runs:
using: composite
steps:
- name: Building dist for ${{ inputs.target }}
run: node_modules/grunt/bin/grunt releaseci --${{ inputs.target }}
shell: bash
40 changes: 40 additions & 0 deletions .github/actions/notify_slack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: send_slack_notifications
description: Send Slack notification
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 smarttrader.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 smarttrader.deriv.com with version ${{ inputs.VERSION }}"
}' \
${{ inputs.SLACK_WEBHOOK_URL }}
shell: bash

21 changes: 21 additions & 0 deletions .github/actions/npm_install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: npm_install
description: Install npm packages
runs:
using: composite
steps:
- name: restore_cache
uses: actions/[email protected]
with:
key: node-{{ checksum "package-lock.json" }}
path: UPDATE_ME
restore-keys: |-
node-{{ checksum "package-lock.json" }}
node-
- name: Install npm packages
run: npm ci
shell: bash
- name: save_cache
uses: actions/[email protected]
with:
path: node_modules
key: node-{{ checksum "package-lock.json" }}
19 changes: 19 additions & 0 deletions .github/actions/publish_to_pages_production/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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)
run: |-
npm i [email protected]
cd dist
npx wrangler pages deploy . --project-name=deriv-binary-static-pages --branch=main
echo "New website - http://cf-pages-deriv-binary-static.deriv.com"
shell: bash
19 changes: 19 additions & 0 deletions .github/actions/publish_to_pages_staging/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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)
run: |-
npm i [email protected]
cd dist
npx wrangler pages deploy . --project-name=deriv-binary-static-pages --branch=staging
echo "New staging website - http://staging.cf-pages-deriv-binary-static.deriv.com"
shell: bash
10 changes: 10 additions & 0 deletions .github/actions/versioning/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: versioning
inputs:
target_branch:
required: false
runs:
using: composite
steps:
- name: Tag build
run: echo "${{ inputs.target_branch }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > dist/version
shell: bash
81 changes: 81 additions & 0 deletions .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: DSmartTrader Production Release
on:
push:
tags:
- production_*
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 12.22
- name: Install dependencies
uses: "./.github/actions/npm_install"
- name: Build
uses: "./.github/actions/build"
with:
target: production
- uses: "./.github/actions/versioning"
with:
target_branch: production
- name: "Run Tests"
run: npm run test
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
publish_cloudflare_production:
runs-on: ubuntu-latest

needs: [build_and_test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Download Artifacts
uses: actions/[email protected]
with:
path: dist
- uses: "./.github/actions/publish_to_pages_production"

notify_on_slack:
if: always()
runs-on: ubuntu-latest

needs: [publish_cloudflare_production, build_and_test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Conclusion
uses: technote-space/workflow-conclusion-action@v3
- uses: actions/[email protected]
with:
path: dist
- name: Grab Version Name
id: extract_version
run: echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV
- uses: "./.github/actions/notify_slack"
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ env.WORKFLOW_CONCLUSION }}
release_type: Production
version: ${{ steps.extract_version.outputs.RELEASE_VERSION}}

- uses: ./.github/actions/notify_slack
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ env.WORKFLOW_CONCLUSION }}
release_type: Production
version: ${{ steps.extract_version.outputs.RELEASE_VERSION}}
44 changes: 44 additions & 0 deletions .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: DSmartTrader Staging Release
on:
push:
branches:
- master
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 12.22
- name: Install dependencies
uses: "./.github/actions/npm_install"
- name: Build
uses: "./.github/actions/build"
with:
target: production
- uses: "./.github/actions/versioning"
with:
target_branch: production
- name: "Run Tests"
run: npm run test
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
publish_cloudflare_production:
runs-on: ubuntu-latest
needs: [build_and_test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.x
- uses: actions/[email protected]
with:
path: dist
- uses: "./.github/actions/publish_to_pages_production"
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: DSmartTrader Test
on:
pull_request:
branches:
- master
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 12.22
- name: Install dependencies
uses: "./.github/actions/npm_install"
- name: Build
uses: "./.github/actions/build"
with:
target: production
- name: "Run Tests"
run: npm run test
Loading