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

Jim/FEQ-703/convert-circleci-config-on-deriv-api-docs-to-github-workflow #250

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8919b7b
ci: add actions
jim-deriv Oct 4, 2023
e99a075
ci: add workflows
jim-deriv Oct 4, 2023
cc4b26c
build: use node 16 in actions/setup_node
jim-deriv Oct 4, 2023
fe4ff9c
ci: upgrade wrangler
jim-deriv Oct 4, 2023
666fb16
chore: add new line at the end of the file
jim-deriv Oct 4, 2023
88daf13
chore: add new line at the end of the file
jim-deriv Oct 4, 2023
6b25d4a
chore: update tag matcher
jim-deriv Oct 4, 2023
3477a12
chore: format yaml
jim-deriv Oct 4, 2023
7e76341
chore: remove circleci config
jim-deriv Oct 5, 2023
f745a4b
chore: remove unused environment variables
jim-deriv Oct 5, 2023
2e2b915
feat: add readVersion step
jim-deriv Oct 5, 2023
57bcf4a
chore: use the readVersion step
jim-deriv Oct 5, 2023
1a0e165
chore: use the readVersion step and remove unused ca environment vari…
jim-deriv Oct 5, 2023
bba1732
ci: fix file read command
jim-deriv Oct 6, 2023
a55f79e
build: remove unnecessary step
jim-deriv Oct 6, 2023
c4ee7f7
build: remove unnecessary step
jim-deriv Oct 6, 2023
63a92c3
chore: remove unused environment variables
jim-deriv Oct 6, 2023
5945106
Revert "chore: remove circleci config"
jim-deriv Oct 6, 2023
50299e0
chore: capitalise all input names
jim-deriv Oct 6, 2023
7bd1f9f
ci: add step to save cache
jim-deriv Oct 6, 2023
6796ff4
ci: replace codecov with coveralls
jim-deriv Oct 6, 2023
30348bd
chore: update workflow name
jim-deriv Oct 6, 2023
a283dc3
chore: use ubuntu-latest as the runner
jim-deriv Oct 6, 2023
065db58
chore: update path
jim-deriv Oct 6, 2023
b02e7c7
chore: update key
jim-deriv Oct 6, 2023
f522cb9
chore: add command to collect coverage
jim-deriv Oct 6, 2023
844a591
docs: update badge
jim-deriv Oct 6, 2023
d35cc9e
chore: update badge link
jim-deriv Oct 6, 2023
c640c94
docs: add branch name
jim-deriv Oct 6, 2023
e8310d1
Merge branch 'master' of https://github.com/binary-com/deriv-api-docs…
ali-hosseini-deriv Oct 11, 2023
87e71bc
ci: fix node_modules cache
ali-hosseini-deriv Oct 12, 2023
1afd5c1
ci: fix slack notification
ali-hosseini-deriv Oct 12, 2023
525b72f
ci: make it to one line command
ali-hosseini-deriv Oct 12, 2023
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
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
ali-hosseini-deriv marked this conversation as resolved.
Show resolved Hide resolved
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