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

Commit

Permalink
Merge pull request #250 from jim-deriv/Jim/FEQ-703/convert-circleci-c…
Browse files Browse the repository at this point in the history
…onfig-on-deriv-api-docs-to-github-workflow

Jim/FEQ-703/convert-circleci-config-on-deriv-api-docs-to-github-workflow
  • Loading branch information
ali-hosseini-deriv authored Oct 12, 2023
2 parents 3a6ff98 + 525b72f commit 716a52b
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 33 deletions.
15 changes: 15 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: build
description: Build Docusaurus project
inputs:
NODE_ENV:
description: Node environment
required: false
default: staging
runs:
using: composite
steps:
- name: Building Docusaurus project
env:
NODE_ENV: ${{ inputs.NODE_ENV }}
run: npm run build
shell: bash
10 changes: 10 additions & 0 deletions .github/actions/invalidate_master_cache/action.yml
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: ${{ runner.os }}-node_modules-${{ hashFiles('./package-lock.json') }}
37 changes: 37 additions & 0 deletions .github/actions/notify_slack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: notify_slack
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 api.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 api.deriv.com with version *'"${{ inputs.VERSION }}"'*"
}' \
${{ inputs.SLACK_WEBHOOK_URL }}
shell: bash
15 changes: 15 additions & 0 deletions .github/actions/npm_install_from_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: npm_install_from_cache
description: Install npm packages from cache
runs:
using: composite
steps:
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache/restore@v3
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('./package-lock.json') }}
- name: Install npm dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm install
shell: bash
22 changes: 22 additions & 0 deletions .github/actions/publish_to_pages_production/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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]
cd build
npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=main
echo "New website - https://api.deriv.com"
shell: bash
22 changes: 22 additions & 0 deletions .github/actions/publish_to_pages_staging/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: publish_to_pages_staging
description: Publishes 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]
cd build
npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=staging
echo "New staging website - https://staging-api.deriv.com/"
shell: bash
9 changes: 9 additions & 0 deletions .github/actions/setup_node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Setup Node
description: Sets up Node.js
runs:
using: composite
steps:
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
13 changes: 13 additions & 0 deletions .github/actions/versioning/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: versioning
description: Generates a version for the build
inputs:
RELEASE_TYPE:
description: Release Type
required: false
default: staging
runs:
using: composite
steps:
- name: Tag build
run: echo "${{ inputs.RELEASE_TYPE }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version
shell: bash
32 changes: 0 additions & 32 deletions .github/workflows/codecov.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Coveralls Workflow
on:
pull_request:
branches:
- '**'
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: './.github/actions/setup_node'
- name: Install dependencies
uses: './.github/actions/npm_install_from_cache'
- name: Build
uses: ./.github/actions/build
- name: Run Tests
run: npm run test -- --collectCoverage
- name: Coveralls
uses: coverallsapp/github-action@v2
54 changes: 54 additions & 0 deletions .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deriv Api Docs Production Workflow
on:
push:
tags:
- production_v*
jobs:
build_and_publish:
name: Builds and Publishes to Cloudflare Pages Production
environment: Production
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
outputs:
RELEASE_VERSION: ${{ steps.extract_version.outputs.RELEASE_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: ./.github/actions/setup_node
- name: Install dependencies
uses: ./.github/actions/npm_install_from_cache
- name: Build
uses: ./.github/actions/build
with:
NODE_ENV: production
- name: Versioning
uses: ./.github/actions/versioning
with:
RELEASE_TYPE: production
- name: Extract version
id: extract_version
run: echo "RELEASE_VERSION=$(cat build/version)" >> $GITHUB_OUTPUT
- 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 }}
send_slack_notification:
name: Send Slack Notification
environment: Production
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
if: always()
needs:
- build_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/notify_slack
with:
RELEASE_TYPE: Production
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
STATUS: ${{ env.WORKFLOW_CONCLUSION }}
version: ${{ needs.build_and_publish.outputs.RELEASE_VERSION}}
28 changes: 28 additions & 0 deletions .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deriv Api Docs Staging Workflow
on:
push:
branches:
- master
jobs:
build_and_publish:
name: Builds and Publishes to Cloudflare Pages Staging
runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided
environment: Staging
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: ./.github/actions/setup_node
- name: Install Dependencies
uses: ./.github/actions/npm_install_from_cache
- name: Invalidate Cache
uses: ./.github/actions/invalidate_master_cache
- name: Build
uses: ./.github/actions/build
with:
NODE_ENV: 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 }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This repository contains the information and code related to the Deriv API documentation.

![Prerequisite](https://img.shields.io/badge/node-%3E%3D16.16.0-blue.svg)
[![codecov](https://codecov.io/gh/binary-com/deriv-api-docs/branch/master/graph/badge.svg?token=HXCKP3ZTWP)](https://codecov.io/gh/binary-com/deriv-api-docs)
[![Coverage Status](https://coveralls.io/repos/github/binary-com/deriv-api-docs/badge.svg?branch=master)](https://coveralls.io/github/binary-com/deriv-api-docs?branch=master)

<!--
![CircleCI](https://img.shields.io/circleci/build/github/binary-com/deriv-api-docs)
Expand Down

1 comment on commit 716a52b

@vercel
Copy link

@vercel vercel bot commented on 716a52b Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-api-docs – ./

deriv-api-docs-git-master.binary.sx
deriv-api-docs.binary.sx

Please sign in to comment.