-
Notifications
You must be signed in to change notification settings - Fork 61
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 #572 from ali-hosseini-deriv/ako/add-github-actions
Ako/add GitHub actions
- Loading branch information
Showing
9 changed files
with
278 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,11 @@ | ||
name: Build | ||
inputs: | ||
target: | ||
required: true | ||
default: staging | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Building dist for ${{ inputs.target }} | ||
run: node_modules/grunt/bin/grunt releaseci --${{ inputs.target }} | ||
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,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 | ||
|
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: 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" }} |
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,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 |
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,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 |
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: 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 |
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,81 @@ | ||
name: DSmartTrader Production Release | ||
on: | ||
push: | ||
tags: | ||
- production_* | ||
jobs: | ||
build_and_test: | ||
name: 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: | ||
name: Publish to 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 | ||
- name: Publish to Cloudflare | ||
uses: "./.github/actions/publish_to_pages_production" | ||
with: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
|
||
notify_on_slack: | ||
name: 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 | ||
- name: Send Slack Notification | ||
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}} |
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,53 @@ | ||
name: DSmartTrader Staging Release | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
build_and_test: | ||
name: 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 Staging | ||
uses: "./.github/actions/build" | ||
with: | ||
target: staging | ||
- name: Build Translations | ||
uses: "./.github/actions/build" | ||
with: | ||
target: translations | ||
- 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: | ||
name: Publish to Cloudflare Pages 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" | ||
with: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
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,24 @@ | ||
name: DSmartTrader Test | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
build_and_test: | ||
name: 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 |