This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
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 #250 from jim-deriv/Jim/FEQ-703/convert-circleci-c…
…onfig-on-deriv-api-docs-to-github-workflow Jim/FEQ-703/convert-circleci-config-on-deriv-api-docs-to-github-workflow
- Loading branch information
Showing
13 changed files
with
251 additions
and
33 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,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 |
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: 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') }} |
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,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 |
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,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 |
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,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 |
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,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 |
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,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 |
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,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 |
This file was deleted.
Oops, something went wrong.
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,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 |
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,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}} |
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,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 }} |
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
716a52b
There was a problem hiding this comment.
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