Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 716a52b

Browse files
Merge pull request #250 from jim-deriv/Jim/FEQ-703/convert-circleci-config-on-deriv-api-docs-to-github-workflow
Jim/FEQ-703/convert-circleci-config-on-deriv-api-docs-to-github-workflow
2 parents 3a6ff98 + 525b72f commit 716a52b

File tree

13 files changed

+251
-33
lines changed

13 files changed

+251
-33
lines changed

.github/actions/build/action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: build
2+
description: Build Docusaurus project
3+
inputs:
4+
NODE_ENV:
5+
description: Node environment
6+
required: false
7+
default: staging
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Building Docusaurus project
12+
env:
13+
NODE_ENV: ${{ inputs.NODE_ENV }}
14+
run: npm run build
15+
shell: bash
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: invalidate_npm_cache
2+
description: Invalidate the Master NPM cache
3+
runs:
4+
using: composite
5+
steps:
6+
- name: save_cache
7+
uses: actions/cache/save@v3
8+
with:
9+
path: ./node_modules
10+
key: ${{ runner.os }}-node_modules-${{ hashFiles('./package-lock.json') }}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: notify_slack
2+
description: Send Slack notifications
3+
inputs:
4+
SLACK_WEBHOOK_URL:
5+
description: Slack webhook URL
6+
required: true
7+
STATUS:
8+
description: Job status
9+
required: true
10+
RELEASE_TYPE:
11+
description: Release type
12+
required: true
13+
VERSION:
14+
description: Version
15+
required: true
16+
default: N/A
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Send Slack Notification on Success
21+
if: ${{ inputs.STATUS == 'success' }}
22+
run: |-
23+
curl -X POST -H 'Content-type: application/json' \
24+
--data '{
25+
"text": "'"${{ inputs.RELEASE_TYPE }}"' Release succeeded for api.deriv.com with version *'"${{ inputs.VERSION }}"'*"
26+
}' \
27+
${{ inputs.SLACK_WEBHOOK_URL }}
28+
shell: bash
29+
- name: Send Slack Notification on Failure
30+
if: ${{ inputs.STATUS == 'failure' }}
31+
run: |-
32+
curl -X POST -H 'Content-type: application/json' \
33+
--data '{
34+
"text": "'"${{ inputs.RELEASE_TYPE }}"' Release failed for api.deriv.com with version *'"${{ inputs.VERSION }}"'*"
35+
}' \
36+
${{ inputs.SLACK_WEBHOOK_URL }}
37+
shell: bash
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: npm_install_from_cache
2+
description: Install npm packages from cache
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Cache node modules
7+
id: cache-nodemodules
8+
uses: actions/cache/restore@v3
9+
with:
10+
path: node_modules
11+
key: ${{ runner.os }}-node_modules-${{ hashFiles('./package-lock.json') }}
12+
- name: Install npm dependencies
13+
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
14+
run: npm install
15+
shell: bash
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: publish_to_pages_production
2+
description: Publish to cloudflare pages (production)
3+
inputs:
4+
CLOUDFLARE_ACCOUNT_ID:
5+
description: Cloudflare account id
6+
required: true
7+
CLOUDFLARE_API_TOKEN:
8+
description: Cloudflare token
9+
required: true
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Publish to cloudflare pages (production)
14+
env:
15+
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }}
16+
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }}
17+
run: |-
18+
npm i wrangler@3.10.1
19+
cd build
20+
npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=main
21+
echo "New website - https://api.deriv.com"
22+
shell: bash
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: publish_to_pages_staging
2+
description: Publishes to cloudflare pages (staging)
3+
inputs:
4+
CLOUDFLARE_ACCOUNT_ID:
5+
description: Cloudflare account id
6+
required: true
7+
CLOUDFLARE_API_TOKEN:
8+
description: Cloudflare token
9+
required: true
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Publish to cloudflare pages (staging)
14+
env:
15+
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }}
16+
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }}
17+
run: |-
18+
npm i wrangler@3.10.1
19+
cd build
20+
npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=staging
21+
echo "New staging website - https://staging-api.deriv.com/"
22+
shell: bash

.github/actions/setup_node/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Setup Node
2+
description: Sets up Node.js
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Use Node.js 16.x
7+
uses: actions/setup-node@v3
8+
with:
9+
node-version: 16.x

.github/actions/versioning/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: versioning
2+
description: Generates a version for the build
3+
inputs:
4+
RELEASE_TYPE:
5+
description: Release Type
6+
required: false
7+
default: staging
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Tag build
12+
run: echo "${{ inputs.RELEASE_TYPE }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version
13+
shell: bash

.github/workflows/codecov.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/coveralls.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Coveralls Workflow
2+
on:
3+
pull_request:
4+
branches:
5+
- '**'
6+
push:
7+
branches:
8+
- master
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
- name: Setup Node
17+
uses: './.github/actions/setup_node'
18+
- name: Install dependencies
19+
uses: './.github/actions/npm_install_from_cache'
20+
- name: Build
21+
uses: ./.github/actions/build
22+
- name: Run Tests
23+
run: npm run test -- --collectCoverage
24+
- name: Coveralls
25+
uses: coverallsapp/github-action@v2

0 commit comments

Comments
 (0)