From 8919b7b6d1f346d453eaf0ddf39249a26c6a06c3 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Wed, 4 Oct 2023 15:00:53 +0800 Subject: [PATCH 01/32] ci: add actions --- .github/actions/build/action.yml | 59 +++++++++++++++++++ .github/actions/notify_slack/action.yml | 38 ++++++++++++ .../actions/npm_install_from_cache/action.yml | 15 +++++ .../publish_to_pages_production/action.yml | 26 ++++++++ .../publish_to_pages_staging/action.yml | 26 ++++++++ .github/actions/setup_node/action.yml | 9 +++ .github/actions/versioning/action.yml | 13 ++++ 7 files changed, 186 insertions(+) create mode 100644 .github/actions/build/action.yml create mode 100644 .github/actions/notify_slack/action.yml create mode 100644 .github/actions/npm_install_from_cache/action.yml create mode 100644 .github/actions/publish_to_pages_production/action.yml create mode 100644 .github/actions/publish_to_pages_staging/action.yml create mode 100644 .github/actions/setup_node/action.yml create mode 100644 .github/actions/versioning/action.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 00000000..0b62cc92 --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,59 @@ +name: build +description: 'Build Docusaurus project' +inputs: + CA_CRT: + description: 'CA certificate' + required: false + CA: + description: 'CA' + required: false + CONTEXT_ARTIFACT_S3_BUCKET: + description: 'Context artifact S3 bucket' + required: false + DATADOG_APPLICATION_ID: + description: 'Datadog application ID' + required: false + DATADOG_CLIENT_TOKEN: + description: 'Datadog client token' + required: false + DOCKERHUB_ORGANISATION: + description: 'Dockerhub organisation' + required: false + DOCKERHUB_PASSWORD: + description: 'Dockerhub password' + required: false + DOCKERHUB_USERNAME: + description: 'Dockerhub username' + required: false + DOCKHUB_ORGANISATION: + description: 'Dockerhub organisation' + required: false + KUBE_SERVER: + description: 'Kubernetes server' + required: false + SERVICEACCOUNT_TOKEN: + description: Service account token + required: false + NODE_ENV: + description: Node environment + required: false + default: 'staging' +runs: + using: composite + steps: + - name: Building Docusaurus project + env: + NODE_ENV: ${{ inputs.NODE_ENV }} + CA: ${{ inputs.CA }} + CA_CRT: ${{ inputs.CA_CRT }} + CONTEXT_ARTIFACT_S3_BUCKET: ${{ inputs.CONTEXT_ARTIFACT_S3_BUCKET }} + DATADOG_APPLICATION_ID: ${{ inputs.DATADOG_APPLICATION_ID }} + DATADOG_CLIENT_TOKEN: ${{ inputs.DATADOG_CLIENT_TOKEN }} + DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }} + DOCKERHUB_PASSWORD: ${{inputs.DOCKERHUB_PASSWORD}} + DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }} + DOCKHUB_ORGANISATION: ${{ inputs.DOCKHUB_ORGANISATION }} + KUBE_SERVER: ${{ inputs.KUBE_SERVER }} + SERVICEACCOUNT_TOKEN: ${{ inputs.SERVICEACCOUNT_TOKEN }} + run: npm run build + shell: bash \ No newline at end of file diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml new file mode 100644 index 00000000..6df0b9a6 --- /dev/null +++ b/.github/actions/notify_slack/action.yml @@ -0,0 +1,38 @@ +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 }}"'*" + }' \ + $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 }}"'*" + }' \ + $SLACK_WEBHOOK_URL + shell: bash \ No newline at end of file diff --git a/.github/actions/npm_install_from_cache/action.yml b/.github/actions/npm_install_from_cache/action.yml new file mode 100644 index 00000000..68dd5ce6 --- /dev/null +++ b/.github/actions/npm_install_from_cache/action.yml @@ -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: + key: v1-deps-{{ checksum "package-lock.json" }} + path: node_modules + - name: Install npm dependencies + if: steps.cache-nodemodules.outputs.cache-hit != 'true' + run: npm install + shell: bash \ No newline at end of file diff --git a/.github/actions/publish_to_pages_production/action.yml b/.github/actions/publish_to_pages_production/action.yml new file mode 100644 index 00000000..b865b8e0 --- /dev/null +++ b/.github/actions/publish_to_pages_production/action.yml @@ -0,0 +1,26 @@ +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 + version: + description: 'Version of the app to release' + 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 }} + version: ${{ inputs.version }} + run: |- + npm i wrangler@2.0.19 + cd build + npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=main + echo "New website - https://api.deriv.com" + shell: bash \ No newline at end of file diff --git a/.github/actions/publish_to_pages_staging/action.yml b/.github/actions/publish_to_pages_staging/action.yml new file mode 100644 index 00000000..dca0ec3c --- /dev/null +++ b/.github/actions/publish_to_pages_staging/action.yml @@ -0,0 +1,26 @@ +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 + version: + description: 'Version of the app to release' + 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 }} + version: ${{ inputs.version }} + run: |- + npm i wrangler@2.0.19 + cd build + npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=staging + echo "New staging website - https://staging-api.deriv.com/" + shell: bash \ No newline at end of file diff --git a/.github/actions/setup_node/action.yml b/.github/actions/setup_node/action.yml new file mode 100644 index 00000000..6e83a969 --- /dev/null +++ b/.github/actions/setup_node/action.yml @@ -0,0 +1,9 @@ +name: Setup Node +description: 'Sets up Node.js' +runs: + using: composite + steps: + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x \ No newline at end of file diff --git a/.github/actions/versioning/action.yml b/.github/actions/versioning/action.yml new file mode 100644 index 00000000..96704500 --- /dev/null +++ b/.github/actions/versioning/action.yml @@ -0,0 +1,13 @@ +name: versioning +description: Generates a version for the build +inputs: + version_name: + description: Version name + required: false + default: staging +runs: + using: composite + steps: + - name: Tag build + run: echo "${{ inputs.version_name }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version + shell: bash \ No newline at end of file From e99a07504f0e1fa5e82bb93437e5a8ad2ac66e7d Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Wed, 4 Oct 2023 15:02:31 +0800 Subject: [PATCH 02/32] ci: add workflows --- .github/workflows/release_production.yml | 63 ++++++++++++++++++++++++ .github/workflows/release_staging.yml | 42 ++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 .github/workflows/release_production.yml create mode 100644 .github/workflows/release_staging.yml diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml new file mode 100644 index 00000000..8c1b1a74 --- /dev/null +++ b/.github/workflows/release_production.yml @@ -0,0 +1,63 @@ +name: Deriv Api Docs Production Workflow +on: + push: + tags: + - production.* +jobs: + build_and_publish: + name : Builds and Publishes to Cloudflare Pages Production + environment: Production # need to setup the environment variables like they were setup for deriv-app + runs-on: Runner_16cores_Deriv-app # 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" + with: + CA_CRT: ${{ secrets.CA_CRT }} # Verify the enviroment variables are defined in the repository + CA: ${{ secrets.CA }} + CONTEXT_ARTIFACT_S3_BUCKET: ${{ vars.CONTEXT_ARTIFACT_S3_BUCKET }} + DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} + DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} + DOCKERHUB_ORGANISATION: ${{ vars.DOCKERHUB_ORGANISATION }} + DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKHUB_ORGANISATION: ${{ vars.DOCKHUB_ORGANISATION }} # Verify this is needed + KUBE_SERVER: ${{ secrets.KUBE_SERVER }} + NODE_ENV: production + SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} + - name: Versioning + uses: "./.github/actions/versioning" + with: + version_name: production + - 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 }} + version: $(echo cat build/version | bash) + + + send_slack_notification: + name: Send Slack Notification + environment: Production # need to setup the environment variables like they were setup for deriv-app + runs-on: Runner_16cores_Deriv-app # 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: $(echo cat build/version | bash) + diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml new file mode 100644 index 00000000..6e9bbf94 --- /dev/null +++ b/.github/workflows/release_staging.yml @@ -0,0 +1,42 @@ +name: Deriv Api Docs Staging Workflow +on: + push: + branches: + - master +jobs: + build_and_publish: + name: Builds and Publishes to Cloudflare Pages Staging + runs-on: Runner_16cores_Deriv-app # 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: Build + uses: "./.github/actions/build" + with: + CA_CRT: ${{ secrets.CA_CRT }} + CA: ${{ secrets.CA }} + CONTEXT_ARTIFACT_S3_BUCKET: ${{ secrets.CONTEXT_ARTIFACT_S3_BUCKET }} + DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} + DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} + DOCKERHUB_ORGANISATION: ${{ vars.DOCKERHUB_ORGANISATION }} + DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKHUB_ORGANISATION: ${{ vars.DOCKHUB_ORGANISATION }} + KUBE_SERVER: ${{ secrets.KUBE_SERVER }} + NODE_ENV: staging + SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} + - name: Versioning + uses: "./.github/actions/versioning" + with: + version_name: 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 }} + version: $(echo cat build/version | bash) From cc4b26cb92d8e0ef2cba92195fdb74b42edc4c09 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Wed, 4 Oct 2023 15:06:59 +0800 Subject: [PATCH 03/32] build: use node 16 in actions/setup_node --- .github/actions/setup_node/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup_node/action.yml b/.github/actions/setup_node/action.yml index 6e83a969..83aece95 100644 --- a/.github/actions/setup_node/action.yml +++ b/.github/actions/setup_node/action.yml @@ -3,7 +3,7 @@ description: 'Sets up Node.js' runs: using: composite steps: - - name: Use Node.js 18.x + - name: Use Node.js 16.x uses: actions/setup-node@v3 with: - node-version: 18.x \ No newline at end of file + node-version: 16.x \ No newline at end of file From fe4ff9c9997c95785e5159ac2249e1829620a572 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Wed, 4 Oct 2023 15:17:54 +0800 Subject: [PATCH 04/32] ci: upgrade wrangler --- .github/actions/publish_to_pages_production/action.yml | 4 ++-- .github/actions/publish_to_pages_staging/action.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/publish_to_pages_production/action.yml b/.github/actions/publish_to_pages_production/action.yml index b865b8e0..6eb2701f 100644 --- a/.github/actions/publish_to_pages_production/action.yml +++ b/.github/actions/publish_to_pages_production/action.yml @@ -19,8 +19,8 @@ runs: CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} version: ${{ inputs.version }} run: |- - npm i wrangler@2.0.19 + npm i wrangler@3.10.1 cd build - npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=main + npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=main echo "New website - https://api.deriv.com" shell: bash \ No newline at end of file diff --git a/.github/actions/publish_to_pages_staging/action.yml b/.github/actions/publish_to_pages_staging/action.yml index dca0ec3c..b626e1e4 100644 --- a/.github/actions/publish_to_pages_staging/action.yml +++ b/.github/actions/publish_to_pages_staging/action.yml @@ -19,8 +19,8 @@ runs: CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} version: ${{ inputs.version }} run: |- - npm i wrangler@2.0.19 + npm i wrangler@3.10.1 cd build - npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=staging + npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=staging echo "New staging website - https://staging-api.deriv.com/" shell: bash \ No newline at end of file From 666fb1632950ba892da2c6564149be7f7bacb6e0 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Wed, 4 Oct 2023 15:32:44 +0800 Subject: [PATCH 05/32] chore: add new line at the end of the file --- .github/actions/build/action.yml | 2 +- .github/actions/notify_slack/action.yml | 2 +- .github/actions/npm_install_from_cache/action.yml | 2 +- .github/actions/publish_to_pages_production/action.yml | 2 +- .github/actions/publish_to_pages_staging/action.yml | 2 +- .github/actions/setup_node/action.yml | 2 +- .github/workflows/release_production.yml | 1 - 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 0b62cc92..9b72160e 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -56,4 +56,4 @@ runs: KUBE_SERVER: ${{ inputs.KUBE_SERVER }} SERVICEACCOUNT_TOKEN: ${{ inputs.SERVICEACCOUNT_TOKEN }} run: npm run build - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml index 6df0b9a6..172d226d 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -35,4 +35,4 @@ runs: "text": "'"${{ inputs.release_type }}"' Release failed for api.deriv.com with version *'"${{ inputs.version }}"'*" }' \ $SLACK_WEBHOOK_URL - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/actions/npm_install_from_cache/action.yml b/.github/actions/npm_install_from_cache/action.yml index 68dd5ce6..5ab22446 100644 --- a/.github/actions/npm_install_from_cache/action.yml +++ b/.github/actions/npm_install_from_cache/action.yml @@ -12,4 +12,4 @@ runs: - name: Install npm dependencies if: steps.cache-nodemodules.outputs.cache-hit != 'true' run: npm install - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/actions/publish_to_pages_production/action.yml b/.github/actions/publish_to_pages_production/action.yml index 6eb2701f..30ddbde5 100644 --- a/.github/actions/publish_to_pages_production/action.yml +++ b/.github/actions/publish_to_pages_production/action.yml @@ -23,4 +23,4 @@ runs: cd build npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=main echo "New website - https://api.deriv.com" - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/actions/publish_to_pages_staging/action.yml b/.github/actions/publish_to_pages_staging/action.yml index b626e1e4..5b98791f 100644 --- a/.github/actions/publish_to_pages_staging/action.yml +++ b/.github/actions/publish_to_pages_staging/action.yml @@ -23,4 +23,4 @@ runs: 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 \ No newline at end of file + shell: bash diff --git a/.github/actions/setup_node/action.yml b/.github/actions/setup_node/action.yml index 83aece95..16e8e0c7 100644 --- a/.github/actions/setup_node/action.yml +++ b/.github/actions/setup_node/action.yml @@ -6,4 +6,4 @@ runs: - name: Use Node.js 16.x uses: actions/setup-node@v3 with: - node-version: 16.x \ No newline at end of file + node-version: 16.x diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 8c1b1a74..2edfffc9 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -60,4 +60,3 @@ jobs: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} status: ${{ env.WORKFLOW_CONCLUSION }} version: $(echo cat build/version | bash) - From 88daf13ba7dc586a90eb1c476c909defd2ba7595 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Wed, 4 Oct 2023 15:34:06 +0800 Subject: [PATCH 06/32] chore: add new line at the end of the file --- .github/actions/versioning/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/versioning/action.yml b/.github/actions/versioning/action.yml index 96704500..56e52e1f 100644 --- a/.github/actions/versioning/action.yml +++ b/.github/actions/versioning/action.yml @@ -10,4 +10,4 @@ runs: steps: - name: Tag build run: echo "${{ inputs.version_name }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version - shell: bash \ No newline at end of file + shell: bash From 6b25d4a53b3e51d014c42dbcc0747a092958ac06 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Wed, 4 Oct 2023 15:55:54 +0800 Subject: [PATCH 07/32] chore: update tag matcher --- .github/actions/notify_slack/action.yml | 28 +++++++++---------- .../actions/npm_install_from_cache/action.yml | 20 ++++++------- .../publish_to_pages_production/action.yml | 22 +++++++-------- .../publish_to_pages_staging/action.yml | 22 +++++++-------- .github/actions/setup_node/action.yml | 10 +++---- .github/actions/versioning/action.yml | 6 ++-- .github/workflows/release_production.yml | 25 ++++++++--------- .github/workflows/release_staging.yml | 20 ++++++------- 8 files changed, 76 insertions(+), 77 deletions(-) diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml index 172d226d..eb892f04 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -17,22 +17,22 @@ inputs: runs: using: composite steps: - - name: Send Slack Notification on Success - if: inputs.status == 'success' - run: |- + - 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 }}"'*" }' \ $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 }}"'*" - }' \ - $SLACK_WEBHOOK_URL - shell: bash + 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 }}"'*" + }' \ + $SLACK_WEBHOOK_URL + shell: bash diff --git a/.github/actions/npm_install_from_cache/action.yml b/.github/actions/npm_install_from_cache/action.yml index 5ab22446..e2e0c2db 100644 --- a/.github/actions/npm_install_from_cache/action.yml +++ b/.github/actions/npm_install_from_cache/action.yml @@ -3,13 +3,13 @@ description: Install npm packages from cache runs: using: composite steps: - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache/restore@v3 - with: - key: v1-deps-{{ checksum "package-lock.json" }} - path: node_modules - - name: Install npm dependencies - if: steps.cache-nodemodules.outputs.cache-hit != 'true' - run: npm install - shell: bash + - name: Cache node modules + id: cache-nodemodules + uses: actions/cache/restore@v3 + with: + key: v1-deps-{{ checksum "package-lock.json" }} + path: node_modules + - name: Install npm dependencies + if: steps.cache-nodemodules.outputs.cache-hit != 'true' + run: npm install + shell: bash diff --git a/.github/actions/publish_to_pages_production/action.yml b/.github/actions/publish_to_pages_production/action.yml index 30ddbde5..8332338f 100644 --- a/.github/actions/publish_to_pages_production/action.yml +++ b/.github/actions/publish_to_pages_production/action.yml @@ -13,14 +13,14 @@ inputs: 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 }} - version: ${{ inputs.version }} - run: |- - npm i wrangler@3.10.1 - cd build - npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=main - echo "New website - https://api.deriv.com" - shell: bash + - name: Publish to cloudflare pages (production) + env: + CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} + version: ${{ inputs.version }} + run: |- + npm i wrangler@3.10.1 + cd build + npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=main + echo "New website - https://api.deriv.com" + shell: bash diff --git a/.github/actions/publish_to_pages_staging/action.yml b/.github/actions/publish_to_pages_staging/action.yml index 5b98791f..566a9e39 100644 --- a/.github/actions/publish_to_pages_staging/action.yml +++ b/.github/actions/publish_to_pages_staging/action.yml @@ -13,14 +13,14 @@ inputs: 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 }} - version: ${{ inputs.version }} - run: |- - npm i wrangler@3.10.1 - 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 + - name: Publish to cloudflare pages (staging) + env: + CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} + version: ${{ inputs.version }} + run: |- + npm i wrangler@3.10.1 + 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 diff --git a/.github/actions/setup_node/action.yml b/.github/actions/setup_node/action.yml index 16e8e0c7..eb906fba 100644 --- a/.github/actions/setup_node/action.yml +++ b/.github/actions/setup_node/action.yml @@ -1,9 +1,9 @@ name: Setup Node description: 'Sets up Node.js' -runs: +runs: using: composite steps: - - name: Use Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x + - name: Use Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16.x diff --git a/.github/actions/versioning/action.yml b/.github/actions/versioning/action.yml index 56e52e1f..800f2f5c 100644 --- a/.github/actions/versioning/action.yml +++ b/.github/actions/versioning/action.yml @@ -8,6 +8,6 @@ inputs: runs: using: composite steps: - - name: Tag build - run: echo "${{ inputs.version_name }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version - shell: bash + - name: Tag build + run: echo "${{ inputs.version_name }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version + shell: bash diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 2edfffc9..80fa5889 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -2,26 +2,26 @@ name: Deriv Api Docs Production Workflow on: push: tags: - - production.* + - production_v* jobs: build_and_publish: - name : Builds and Publishes to Cloudflare Pages Production + name: Builds and Publishes to Cloudflare Pages Production environment: Production # need to setup the environment variables like they were setup for deriv-app runs-on: Runner_16cores_Deriv-app # 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" + uses: './.github/actions/setup_node' - name: Install dependencies - uses: "./.github/actions/npm_install_from_cache" + uses: './.github/actions/npm_install_from_cache' - name: Build - uses: "./.github/actions/build" + uses: './.github/actions/build' with: - CA_CRT: ${{ secrets.CA_CRT }} # Verify the enviroment variables are defined in the repository + CA_CRT: ${{ secrets.CA_CRT }} # Verify the enviroment variables are defined in the repository CA: ${{ secrets.CA }} CONTEXT_ARTIFACT_S3_BUCKET: ${{ vars.CONTEXT_ARTIFACT_S3_BUCKET }} - DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} + DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} DOCKERHUB_ORGANISATION: ${{ vars.DOCKERHUB_ORGANISATION }} DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} @@ -31,17 +31,16 @@ jobs: NODE_ENV: production SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - name: Versioning - uses: "./.github/actions/versioning" + uses: './.github/actions/versioning' with: version_name: production - name: Publish to Cloudflare Pages Production - uses: "./.github/actions/publish_to_pages_production" + uses: './.github/actions/publish_to_pages_production' with: - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} version: $(echo cat build/version | bash) - send_slack_notification: name: Send Slack Notification environment: Production # need to setup the environment variables like they were setup for deriv-app @@ -54,9 +53,9 @@ jobs: - name: Conclusion uses: technote-space/workflow-conclusion-action@v3 - name: Send Slack Notification - uses: "./.github/actions/notify_slack" + uses: './.github/actions/notify_slack' with: - release_type: Production + release_type: Production SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} status: ${{ env.WORKFLOW_CONCLUSION }} version: $(echo cat build/version | bash) diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 6e9bbf94..7d4e549f 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -2,7 +2,7 @@ name: Deriv Api Docs Staging Workflow on: push: branches: - - master + - master jobs: build_and_publish: name: Builds and Publishes to Cloudflare Pages Staging @@ -12,30 +12,30 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Node - uses: "./.github/actions/setup_node" + uses: './.github/actions/setup_node' - name: Install Dependencies - uses: "./.github/actions/npm_install_from_cache" + uses: './.github/actions/npm_install_from_cache' - name: Build - uses: "./.github/actions/build" + uses: './.github/actions/build' with: CA_CRT: ${{ secrets.CA_CRT }} CA: ${{ secrets.CA }} CONTEXT_ARTIFACT_S3_BUCKET: ${{ secrets.CONTEXT_ARTIFACT_S3_BUCKET }} - DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} + DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} DOCKERHUB_ORGANISATION: ${{ vars.DOCKERHUB_ORGANISATION }} DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKHUB_ORGANISATION: ${{ vars.DOCKHUB_ORGANISATION }} - KUBE_SERVER: ${{ secrets.KUBE_SERVER }} + DOCKHUB_ORGANISATION: ${{ vars.DOCKHUB_ORGANISATION }} + KUBE_SERVER: ${{ secrets.KUBE_SERVER }} NODE_ENV: staging - SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} + SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - name: Versioning - uses: "./.github/actions/versioning" + uses: './.github/actions/versioning' with: version_name: staging - name: Publish to Cloudflare Pages Staging - uses: "./.github/actions/publish_to_pages_staging" + uses: './.github/actions/publish_to_pages_staging' with: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} From 3477a12dbb87e4d5933911b89f75aeb04c146839 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Wed, 4 Oct 2023 17:31:32 +0800 Subject: [PATCH 08/32] chore: format yaml --- .github/actions/build/action.yml | 62 +++++++++---------- .github/actions/notify_slack/action.yml | 11 ++-- .../publish_to_pages_production/action.yml | 9 ++- .../publish_to_pages_staging/action.yml | 9 ++- .github/actions/setup_node/action.yml | 2 +- .github/workflows/release_production.yml | 24 +++---- .github/workflows/release_staging.yml | 10 +-- 7 files changed, 66 insertions(+), 61 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 9b72160e..3d3788e8 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,35 +1,35 @@ name: build -description: 'Build Docusaurus project' +description: Build Docusaurus project inputs: CA_CRT: - description: 'CA certificate' + description: CA certificate required: false - CA: - description: 'CA' + CA: + description: CA required: false CONTEXT_ARTIFACT_S3_BUCKET: - description: 'Context artifact S3 bucket' + description: Context artifact S3 bucket required: false DATADOG_APPLICATION_ID: - description: 'Datadog application ID' + description: Datadog application ID required: false DATADOG_CLIENT_TOKEN: - description: 'Datadog client token' + description: Datadog client token required: false DOCKERHUB_ORGANISATION: - description: 'Dockerhub organisation' + description: Dockerhub organisation required: false DOCKERHUB_PASSWORD: - description: 'Dockerhub password' + description: Dockerhub password required: false DOCKERHUB_USERNAME: - description: 'Dockerhub username' + description: Dockerhub username + required: false + DOCKHUB_ORGANISATION: + description: Dockerhub organisation required: false - DOCKHUB_ORGANISATION: - description: 'Dockerhub organisation' - required: false KUBE_SERVER: - description: 'Kubernetes server' + description: Kubernetes server required: false SERVICEACCOUNT_TOKEN: description: Service account token @@ -37,23 +37,23 @@ inputs: NODE_ENV: description: Node environment required: false - default: 'staging' + default: staging runs: using: composite steps: - - name: Building Docusaurus project - env: - NODE_ENV: ${{ inputs.NODE_ENV }} - CA: ${{ inputs.CA }} - CA_CRT: ${{ inputs.CA_CRT }} - CONTEXT_ARTIFACT_S3_BUCKET: ${{ inputs.CONTEXT_ARTIFACT_S3_BUCKET }} - DATADOG_APPLICATION_ID: ${{ inputs.DATADOG_APPLICATION_ID }} - DATADOG_CLIENT_TOKEN: ${{ inputs.DATADOG_CLIENT_TOKEN }} - DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }} - DOCKERHUB_PASSWORD: ${{inputs.DOCKERHUB_PASSWORD}} - DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }} - DOCKHUB_ORGANISATION: ${{ inputs.DOCKHUB_ORGANISATION }} - KUBE_SERVER: ${{ inputs.KUBE_SERVER }} - SERVICEACCOUNT_TOKEN: ${{ inputs.SERVICEACCOUNT_TOKEN }} - run: npm run build - shell: bash + - name: Building Docusaurus project + env: + NODE_ENV: ${{ inputs.NODE_ENV }} + CA: ${{ inputs.CA }} + CA_CRT: ${{ inputs.CA_CRT }} + CONTEXT_ARTIFACT_S3_BUCKET: ${{ inputs.CONTEXT_ARTIFACT_S3_BUCKET }} + DATADOG_APPLICATION_ID: ${{ inputs.DATADOG_APPLICATION_ID }} + DATADOG_CLIENT_TOKEN: ${{ inputs.DATADOG_CLIENT_TOKEN }} + DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }} + DOCKERHUB_PASSWORD: ${{inputs.DOCKERHUB_PASSWORD}} + DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }} + DOCKHUB_ORGANISATION: ${{ inputs.DOCKHUB_ORGANISATION }} + KUBE_SERVER: ${{ inputs.KUBE_SERVER }} + SERVICEACCOUNT_TOKEN: ${{ inputs.SERVICEACCOUNT_TOKEN }} + run: npm run build + shell: bash diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml index eb892f04..f1de30a9 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -2,18 +2,18 @@ name: notify_slack description: Send Slack notifications inputs: SLACK_WEBHOOK_URL: - description: 'Slack webhook URL' + description: Slack webhook URL required: true status: - description: 'Job status' + description: Job status required: true release_type: - description: 'Release type' + description: Release type required: true version: - description: 'Version' + description: Version required: true - default: 'N/A' + default: N/A runs: using: composite steps: @@ -26,7 +26,6 @@ runs: }' \ $SLACK_WEBHOOK_URL shell: bash - - name: Send Slack Notification on Failure if: inputs.status == 'failure' run: |- diff --git a/.github/actions/publish_to_pages_production/action.yml b/.github/actions/publish_to_pages_production/action.yml index 8332338f..5976f5dd 100644 --- a/.github/actions/publish_to_pages_production/action.yml +++ b/.github/actions/publish_to_pages_production/action.yml @@ -2,13 +2,13 @@ name: publish_to_pages_production description: Publish to cloudflare pages (production) inputs: CLOUDFLARE_ACCOUNT_ID: - description: 'Cloudflare account id' + description: Cloudflare account id required: true CLOUDFLARE_API_TOKEN: - description: 'Cloudflare token' + description: Cloudflare token required: true version: - description: 'Version of the app to release' + description: Version of the app to release required: true runs: using: composite @@ -20,7 +20,10 @@ runs: version: ${{ inputs.version }} run: |- npm i wrangler@3.10.1 + cd build + npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=main + echo "New website - https://api.deriv.com" shell: bash diff --git a/.github/actions/publish_to_pages_staging/action.yml b/.github/actions/publish_to_pages_staging/action.yml index 566a9e39..30d27eb5 100644 --- a/.github/actions/publish_to_pages_staging/action.yml +++ b/.github/actions/publish_to_pages_staging/action.yml @@ -2,13 +2,13 @@ name: publish_to_pages_staging description: Publishes to cloudflare pages (staging) inputs: CLOUDFLARE_ACCOUNT_ID: - description: 'Cloudflare account id' + description: Cloudflare account id required: true CLOUDFLARE_API_TOKEN: - description: 'Cloudflare token' + description: Cloudflare token required: true version: - description: 'Version of the app to release' + description: Version of the app to release required: true runs: using: composite @@ -20,7 +20,10 @@ runs: version: ${{ inputs.version }} run: |- npm i wrangler@3.10.1 + 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 diff --git a/.github/actions/setup_node/action.yml b/.github/actions/setup_node/action.yml index eb906fba..4b60f3cd 100644 --- a/.github/actions/setup_node/action.yml +++ b/.github/actions/setup_node/action.yml @@ -1,5 +1,5 @@ name: Setup Node -description: 'Sets up Node.js' +description: Sets up Node.js runs: using: composite steps: diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 80fa5889..6a749563 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -6,19 +6,19 @@ on: jobs: build_and_publish: name: Builds and Publishes to Cloudflare Pages Production - environment: Production # need to setup the environment variables like they were setup for deriv-app + environment: Production runs-on: Runner_16cores_Deriv-app # 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' + uses: ./.github/actions/setup_node - name: Install dependencies - uses: './.github/actions/npm_install_from_cache' + uses: ./.github/actions/npm_install_from_cache - name: Build - uses: './.github/actions/build' + uses: ./.github/actions/build with: - CA_CRT: ${{ secrets.CA_CRT }} # Verify the enviroment variables are defined in the repository + CA_CRT: ${{ secrets.CA_CRT }} CA: ${{ secrets.CA }} CONTEXT_ARTIFACT_S3_BUCKET: ${{ vars.CONTEXT_ARTIFACT_S3_BUCKET }} DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} @@ -26,34 +26,34 @@ jobs: DOCKERHUB_ORGANISATION: ${{ vars.DOCKERHUB_ORGANISATION }} DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKHUB_ORGANISATION: ${{ vars.DOCKHUB_ORGANISATION }} # Verify this is needed + DOCKHUB_ORGANISATION: ${{ vars.DOCKHUB_ORGANISATION }} KUBE_SERVER: ${{ secrets.KUBE_SERVER }} NODE_ENV: production SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - name: Versioning - uses: './.github/actions/versioning' + uses: ./.github/actions/versioning with: version_name: production - name: Publish to Cloudflare Pages Production - uses: './.github/actions/publish_to_pages_production' + uses: ./.github/actions/publish_to_pages_production with: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} version: $(echo cat build/version | bash) - send_slack_notification: name: Send Slack Notification - environment: Production # need to setup the environment variables like they were setup for deriv-app + environment: Production runs-on: Runner_16cores_Deriv-app # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided if: always() - needs: [build_and_publish] + 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' + uses: ./.github/actions/notify_slack with: release_type: Production SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 7d4e549f..6f0c320d 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -12,11 +12,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Node - uses: './.github/actions/setup_node' + uses: ./.github/actions/setup_node - name: Install Dependencies - uses: './.github/actions/npm_install_from_cache' + uses: ./.github/actions/npm_install_from_cache - name: Build - uses: './.github/actions/build' + uses: ./.github/actions/build with: CA_CRT: ${{ secrets.CA_CRT }} CA: ${{ secrets.CA }} @@ -31,11 +31,11 @@ jobs: NODE_ENV: staging SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - name: Versioning - uses: './.github/actions/versioning' + uses: ./.github/actions/versioning with: version_name: staging - name: Publish to Cloudflare Pages Staging - uses: './.github/actions/publish_to_pages_staging' + uses: ./.github/actions/publish_to_pages_staging with: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} From 7e76341fc021191fab89f09b34c3c3cbe2a1c240 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Thu, 5 Oct 2023 13:57:36 +0800 Subject: [PATCH 09/32] chore: remove circleci config --- .circleci/config.yml | 117 ------------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 4b686c70..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,117 +0,0 @@ -version: 2.1 -orbs: - slack: circleci/slack@3.4.2 -commands: - npm_install_from_cache: - description: "npm install and save cache" - steps: - - restore_cache: - key: v1-deps-{{ checksum "package-lock.json" }} - - run: - name: Install npm dependencies - command: npm install - - save_cache: - key: v1-deps-{{ checksum "package-lock.json" }} - paths: - - node_modules - build: - description: "Build Docusaurus project" - steps: - - run: - name: Building Docusaurus project - command: npm run build - - versioning: - description: "Versioning the image" - parameters: - version_name: - type: string - default: "staging" - steps: - - run: - name: Tag build - command: echo "<< parameters.version_name >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version - - notify_slack: - description: "Notify slack" - steps: - - slack/status: - include_project_field: false - failure_message: "Release failed for api.deriv.com with version *$(cat build/version)*" - success_message: "Release succeeded for api.deriv.com with version *$(cat build/version)*" - webhook: ${SLACK_WEBHOOK} - publish_to_pages_staging: - description: "Publish to cloudflare pages" - steps: - - run: - name: "Publish to cloudflare pages (staging)" - command: | - npm i wrangler@2.0.19 - cd build - npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=staging - echo "New staging website - https://staging-api.deriv.com/" - - publish_to_pages_production: - description: "Publish to cloudflare pages" - steps: - - run: - name: "Publish to cloudflare pages (production)" - command: | - npm i wrangler@2.0.19 - cd build - npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=main - echo "New website - https://api.deriv.com" - -jobs: - build: - docker: - - image: cimg/node:18.16.0 - steps: - - checkout - - npm_install_from_cache - - build - - release_staging: - docker: - - image: cimg/node:18.16.0 - steps: - - checkout - - npm_install_from_cache - - build - - versioning - - publish_to_pages_staging - - notify_slack - environment: - NODE_ENV: staging - - release_production: - docker: - - image: cimg/node:18.16.0 - steps: - - checkout - - npm_install_from_cache - - build - - versioning: - version_name: production - - publish_to_pages_production - - notify_slack - environment: - NODE_ENV: production - -workflows: - release_staging: - jobs: - - release_staging: - context: binary-frontend-artifact-upload - filters: - branches: - only: /^master$/ - release_production: - jobs: - - release_production: - context: binary-frontend-artifact-upload - filters: - branches: - ignore: /.*/ - tags: - only: /^production.*/ From f745a4babfddccd57136d5aaa0ce3098febbbc59 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Thu, 5 Oct 2023 16:49:09 +0800 Subject: [PATCH 10/32] chore: remove unused environment variables --- .github/actions/build/action.yml | 34 +----------------------- .github/actions/notify_slack/action.yml | 8 +++--- .github/workflows/release_production.yml | 8 ------ .github/workflows/release_staging.yml | 7 ----- 4 files changed, 5 insertions(+), 52 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 3d3788e8..381f187d 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,12 +1,6 @@ name: build description: Build Docusaurus project inputs: - CA_CRT: - description: CA certificate - required: false - CA: - description: CA - required: false CONTEXT_ARTIFACT_S3_BUCKET: description: Context artifact S3 bucket required: false @@ -16,24 +10,6 @@ inputs: DATADOG_CLIENT_TOKEN: description: Datadog client token required: false - DOCKERHUB_ORGANISATION: - description: Dockerhub organisation - required: false - DOCKERHUB_PASSWORD: - description: Dockerhub password - required: false - DOCKERHUB_USERNAME: - description: Dockerhub username - required: false - DOCKHUB_ORGANISATION: - description: Dockerhub organisation - required: false - KUBE_SERVER: - description: Kubernetes server - required: false - SERVICEACCOUNT_TOKEN: - description: Service account token - required: false NODE_ENV: description: Node environment required: false @@ -43,17 +19,9 @@ runs: steps: - name: Building Docusaurus project env: - NODE_ENV: ${{ inputs.NODE_ENV }} - CA: ${{ inputs.CA }} - CA_CRT: ${{ inputs.CA_CRT }} CONTEXT_ARTIFACT_S3_BUCKET: ${{ inputs.CONTEXT_ARTIFACT_S3_BUCKET }} DATADOG_APPLICATION_ID: ${{ inputs.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ inputs.DATADOG_CLIENT_TOKEN }} - DOCKERHUB_ORGANISATION: ${{ inputs.DOCKERHUB_ORGANISATION }} - DOCKERHUB_PASSWORD: ${{inputs.DOCKERHUB_PASSWORD}} - DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }} - DOCKHUB_ORGANISATION: ${{ inputs.DOCKHUB_ORGANISATION }} - KUBE_SERVER: ${{ inputs.KUBE_SERVER }} - SERVICEACCOUNT_TOKEN: ${{ inputs.SERVICEACCOUNT_TOKEN }} + NODE_ENV: ${{ inputs.NODE_ENV }} run: npm run build shell: bash diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml index f1de30a9..3e80ccf9 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -18,20 +18,20 @@ runs: using: composite steps: - name: Send Slack Notification on Success - if: inputs.status == '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 }}"'*" }' \ - $SLACK_WEBHOOK_URL + ${{ inputs.SLACK_WEBHOOK_URL }} shell: bash - name: Send Slack Notification on Failure - if: inputs.status == '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 }}"'*" }' \ - $SLACK_WEBHOOK_URL + ${{ inputs.SLACK_WEBHOOK_URL }} shell: bash diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 6a749563..684de06d 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -18,18 +18,10 @@ jobs: - name: Build uses: ./.github/actions/build with: - CA_CRT: ${{ secrets.CA_CRT }} - CA: ${{ secrets.CA }} CONTEXT_ARTIFACT_S3_BUCKET: ${{ vars.CONTEXT_ARTIFACT_S3_BUCKET }} DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} - DOCKERHUB_ORGANISATION: ${{ vars.DOCKERHUB_ORGANISATION }} - DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKHUB_ORGANISATION: ${{ vars.DOCKHUB_ORGANISATION }} - KUBE_SERVER: ${{ secrets.KUBE_SERVER }} NODE_ENV: production - SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - name: Versioning uses: ./.github/actions/versioning with: diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 6f0c320d..d2112d7f 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -18,18 +18,11 @@ jobs: - name: Build uses: ./.github/actions/build with: - CA_CRT: ${{ secrets.CA_CRT }} CA: ${{ secrets.CA }} CONTEXT_ARTIFACT_S3_BUCKET: ${{ secrets.CONTEXT_ARTIFACT_S3_BUCKET }} DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} - DOCKERHUB_ORGANISATION: ${{ vars.DOCKERHUB_ORGANISATION }} - DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKHUB_ORGANISATION: ${{ vars.DOCKHUB_ORGANISATION }} - KUBE_SERVER: ${{ secrets.KUBE_SERVER }} NODE_ENV: staging - SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - name: Versioning uses: ./.github/actions/versioning with: From 2e2b9153d361a44ae5beb6a41adf71c491bd0eae Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Thu, 5 Oct 2023 17:33:33 +0800 Subject: [PATCH 11/32] feat: add readVersion step --- .github/workflows/release_production.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 684de06d..3246695b 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -26,12 +26,15 @@ jobs: uses: ./.github/actions/versioning with: version_name: production + - name: Read version file + id: readVersion + run: echo "version=$(cat 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 }} - version: $(echo cat build/version | bash) + version: ${{ steps.readVersion.outputs.version }} send_slack_notification: name: Send Slack Notification environment: Production From 57bcf4ad4286ae2dacfbc42f82475873d8bab3ff Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Thu, 5 Oct 2023 17:43:10 +0800 Subject: [PATCH 12/32] chore: use the readVersion step --- .github/workflows/release_production.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 3246695b..34f52506 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -47,10 +47,13 @@ jobs: uses: actions/checkout@v4 - name: Conclusion uses: technote-space/workflow-conclusion-action@v3 + - name: Read version file + id: readVersion + run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT - 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: $(echo cat build/version | bash) + version: ${{ steps.readVersion.outputs.version }} From 1a0e165357ddf5be13944b2472fef2e13b0d2048 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Thu, 5 Oct 2023 17:45:42 +0800 Subject: [PATCH 13/32] chore: use the readVersion step and remove unused ca environment variable --- .github/workflows/release_staging.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index d2112d7f..b7cb6398 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -18,7 +18,6 @@ jobs: - name: Build uses: ./.github/actions/build with: - CA: ${{ secrets.CA }} CONTEXT_ARTIFACT_S3_BUCKET: ${{ secrets.CONTEXT_ARTIFACT_S3_BUCKET }} DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} @@ -27,9 +26,12 @@ jobs: uses: ./.github/actions/versioning with: version_name: staging + - name: Read version file + id: readVersion + run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT - 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 }} - version: $(echo cat build/version | bash) + version: ${{ steps.readVersion.outputs.version }} From bba173265091b6c8b0182355d324e1bd60f29787 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 10:23:13 +0800 Subject: [PATCH 14/32] ci: fix file read command --- .github/workflows/release_production.yml | 4 ++-- .github/workflows/release_staging.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 34f52506..ebd8f5d0 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -28,7 +28,7 @@ jobs: version_name: production - name: Read version file id: readVersion - run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT + run: echo "version=$(cat build/version)" >> $GITHUB_OUTPUT - name: Publish to Cloudflare Pages Production uses: ./.github/actions/publish_to_pages_production with: @@ -49,7 +49,7 @@ jobs: uses: technote-space/workflow-conclusion-action@v3 - name: Read version file id: readVersion - run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT + run: echo "version=$(cat build/version)" >> $GITHUB_OUTPUT - name: Send Slack Notification uses: ./.github/actions/notify_slack with: diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index b7cb6398..feed6b21 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -28,7 +28,7 @@ jobs: version_name: staging - name: Read version file id: readVersion - run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT + run: echo "version=$(cat build/version)" >> $GITHUB_OUTPUT - name: Publish to Cloudflare Pages Staging uses: ./.github/actions/publish_to_pages_staging with: From a55f79e134c3ce24102ad443adf9816b7fc8d599 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 11:24:03 +0800 Subject: [PATCH 15/32] build: remove unnecessary step --- .../actions/publish_to_pages_production/action.yml | 7 ------- .github/actions/publish_to_pages_staging/action.yml | 7 ------- .github/workflows/release_production.yml | 12 ++++-------- .github/workflows/release_staging.yml | 1 - 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/actions/publish_to_pages_production/action.yml b/.github/actions/publish_to_pages_production/action.yml index 5976f5dd..ca2822f1 100644 --- a/.github/actions/publish_to_pages_production/action.yml +++ b/.github/actions/publish_to_pages_production/action.yml @@ -7,9 +7,6 @@ inputs: CLOUDFLARE_API_TOKEN: description: Cloudflare token required: true - version: - description: Version of the app to release - required: true runs: using: composite steps: @@ -17,13 +14,9 @@ runs: env: CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} - version: ${{ inputs.version }} run: |- npm i wrangler@3.10.1 - cd build - npx wrangler pages deploy . --project-name=deriv-developers-portal-pages --branch=main - echo "New website - https://api.deriv.com" shell: bash diff --git a/.github/actions/publish_to_pages_staging/action.yml b/.github/actions/publish_to_pages_staging/action.yml index 30d27eb5..63e25c8c 100644 --- a/.github/actions/publish_to_pages_staging/action.yml +++ b/.github/actions/publish_to_pages_staging/action.yml @@ -7,9 +7,6 @@ inputs: CLOUDFLARE_API_TOKEN: description: Cloudflare token required: true - version: - description: Version of the app to release - required: true runs: using: composite steps: @@ -17,13 +14,9 @@ runs: env: CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} - version: ${{ inputs.version }} run: |- npm i wrangler@3.10.1 - 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 diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index ebd8f5d0..5e19236e 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -22,19 +22,11 @@ jobs: DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} NODE_ENV: production - - name: Versioning - uses: ./.github/actions/versioning - with: - version_name: production - - name: Read version file - id: readVersion - run: echo "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 }} - version: ${{ steps.readVersion.outputs.version }} send_slack_notification: name: Send Slack Notification environment: Production @@ -47,6 +39,10 @@ jobs: uses: actions/checkout@v4 - name: Conclusion uses: technote-space/workflow-conclusion-action@v3 + - name: Versioning + uses: ./.github/actions/versioning + with: + version_name: production - name: Read version file id: readVersion run: echo "version=$(cat build/version)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index feed6b21..50fa853b 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -34,4 +34,3 @@ jobs: with: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - version: ${{ steps.readVersion.outputs.version }} From c4ee7f7629ddbc144abe6c9d11b5f8f7cd633725 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 11:27:08 +0800 Subject: [PATCH 16/32] build: remove unnecessary step --- .github/workflows/release_staging.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 50fa853b..3d843564 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -22,13 +22,6 @@ jobs: DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} NODE_ENV: staging - - name: Versioning - uses: ./.github/actions/versioning - with: - version_name: staging - - name: Read version file - id: readVersion - run: echo "version=$(cat build/version)" >> $GITHUB_OUTPUT - name: Publish to Cloudflare Pages Staging uses: ./.github/actions/publish_to_pages_staging with: From 63a92c35b8b250ec16560af379c419c81add68cd Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 12:05:50 +0800 Subject: [PATCH 17/32] chore: remove unused environment variables --- .github/actions/build/action.yml | 12 ------------ .github/workflows/release_production.yml | 3 --- .github/workflows/release_staging.yml | 3 --- 3 files changed, 18 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 381f187d..e4dbb33c 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,15 +1,6 @@ name: build description: Build Docusaurus project inputs: - CONTEXT_ARTIFACT_S3_BUCKET: - description: Context artifact S3 bucket - required: false - DATADOG_APPLICATION_ID: - description: Datadog application ID - required: false - DATADOG_CLIENT_TOKEN: - description: Datadog client token - required: false NODE_ENV: description: Node environment required: false @@ -19,9 +10,6 @@ runs: steps: - name: Building Docusaurus project env: - CONTEXT_ARTIFACT_S3_BUCKET: ${{ inputs.CONTEXT_ARTIFACT_S3_BUCKET }} - DATADOG_APPLICATION_ID: ${{ inputs.DATADOG_APPLICATION_ID }} - DATADOG_CLIENT_TOKEN: ${{ inputs.DATADOG_CLIENT_TOKEN }} NODE_ENV: ${{ inputs.NODE_ENV }} run: npm run build shell: bash diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 5e19236e..7acf5e95 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -18,9 +18,6 @@ jobs: - name: Build uses: ./.github/actions/build with: - CONTEXT_ARTIFACT_S3_BUCKET: ${{ vars.CONTEXT_ARTIFACT_S3_BUCKET }} - DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} - DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} NODE_ENV: production - name: Publish to Cloudflare Pages Production uses: ./.github/actions/publish_to_pages_production diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 3d843564..f4e2bf5f 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -18,9 +18,6 @@ jobs: - name: Build uses: ./.github/actions/build with: - CONTEXT_ARTIFACT_S3_BUCKET: ${{ secrets.CONTEXT_ARTIFACT_S3_BUCKET }} - DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} - DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} NODE_ENV: staging - name: Publish to Cloudflare Pages Staging uses: ./.github/actions/publish_to_pages_staging From 59451062bef8a12782dfe3c4a830acfd07769641 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 12:11:52 +0800 Subject: [PATCH 18/32] Revert "chore: remove circleci config" This reverts commit 7e76341fc021191fab89f09b34c3c3cbe2a1c240. --- .circleci/config.yml | 117 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..4b686c70 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,117 @@ +version: 2.1 +orbs: + slack: circleci/slack@3.4.2 +commands: + npm_install_from_cache: + description: "npm install and save cache" + steps: + - restore_cache: + key: v1-deps-{{ checksum "package-lock.json" }} + - run: + name: Install npm dependencies + command: npm install + - save_cache: + key: v1-deps-{{ checksum "package-lock.json" }} + paths: + - node_modules + build: + description: "Build Docusaurus project" + steps: + - run: + name: Building Docusaurus project + command: npm run build + + versioning: + description: "Versioning the image" + parameters: + version_name: + type: string + default: "staging" + steps: + - run: + name: Tag build + command: echo "<< parameters.version_name >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version + + notify_slack: + description: "Notify slack" + steps: + - slack/status: + include_project_field: false + failure_message: "Release failed for api.deriv.com with version *$(cat build/version)*" + success_message: "Release succeeded for api.deriv.com with version *$(cat build/version)*" + webhook: ${SLACK_WEBHOOK} + publish_to_pages_staging: + description: "Publish to cloudflare pages" + steps: + - run: + name: "Publish to cloudflare pages (staging)" + command: | + npm i wrangler@2.0.19 + cd build + npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=staging + echo "New staging website - https://staging-api.deriv.com/" + + publish_to_pages_production: + description: "Publish to cloudflare pages" + steps: + - run: + name: "Publish to cloudflare pages (production)" + command: | + npm i wrangler@2.0.19 + cd build + npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=main + echo "New website - https://api.deriv.com" + +jobs: + build: + docker: + - image: cimg/node:18.16.0 + steps: + - checkout + - npm_install_from_cache + - build + + release_staging: + docker: + - image: cimg/node:18.16.0 + steps: + - checkout + - npm_install_from_cache + - build + - versioning + - publish_to_pages_staging + - notify_slack + environment: + NODE_ENV: staging + + release_production: + docker: + - image: cimg/node:18.16.0 + steps: + - checkout + - npm_install_from_cache + - build + - versioning: + version_name: production + - publish_to_pages_production + - notify_slack + environment: + NODE_ENV: production + +workflows: + release_staging: + jobs: + - release_staging: + context: binary-frontend-artifact-upload + filters: + branches: + only: /^master$/ + release_production: + jobs: + - release_production: + context: binary-frontend-artifact-upload + filters: + branches: + ignore: /.*/ + tags: + only: /^production.*/ From 50299e01807afecfac1d1506d85c91734a2487b1 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 12:41:15 +0800 Subject: [PATCH 19/32] chore: capitalise all input names --- .github/actions/notify_slack/action.yml | 14 +++++++------- .github/actions/versioning/action.yml | 6 +++--- .github/workflows/release_production.yml | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml index 3e80ccf9..a416c5c3 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -4,13 +4,13 @@ inputs: SLACK_WEBHOOK_URL: description: Slack webhook URL required: true - status: + STATUS: description: Job status required: true - release_type: + RELEASE_TYPE: description: Release type required: true - version: + VERSION: description: Version required: true default: N/A @@ -18,20 +18,20 @@ runs: using: composite steps: - name: Send Slack Notification on Success - if: ${{ inputs.status == '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 }}"'*" + "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' }} + 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 }}"'*" + "text": "'"${{ inputs.RELEASE_TYPE }}"' Release failed for api.deriv.com with version *'"${{ inputs.VERSION }}"'*" }' \ ${{ inputs.SLACK_WEBHOOK_URL }} shell: bash diff --git a/.github/actions/versioning/action.yml b/.github/actions/versioning/action.yml index 800f2f5c..1a1f6c07 100644 --- a/.github/actions/versioning/action.yml +++ b/.github/actions/versioning/action.yml @@ -1,13 +1,13 @@ name: versioning description: Generates a version for the build inputs: - version_name: - description: Version name + RELEASE_TYPE: + description: Release Type required: false default: staging runs: using: composite steps: - name: Tag build - run: echo "${{ inputs.version_name }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version + run: echo "${{ inputs.RELEASE_TYPE }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version shell: bash diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 7acf5e95..155bf933 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -39,14 +39,14 @@ jobs: - name: Versioning uses: ./.github/actions/versioning with: - version_name: production - - name: Read version file + RELEASE_TYPE: production + - name: Read from version file id: readVersion run: echo "version=$(cat build/version)" >> $GITHUB_OUTPUT - name: Send Slack Notification uses: ./.github/actions/notify_slack with: - release_type: Production + RELEASE_TYPE: Production SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - status: ${{ env.WORKFLOW_CONCLUSION }} - version: ${{ steps.readVersion.outputs.version }} + STATUS: ${{ env.WORKFLOW_CONCLUSION }} + VERSION: ${{ steps.readVersion.outputs.version }} From 7bd1f9f17a601477e3660efd883cd0f393ba2778 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 14:24:32 +0800 Subject: [PATCH 20/32] ci: add step to save cache --- .github/actions/invalidate_master_cache/action.yml | 11 +++++++++++ .github/actions/npm_install_from_cache/action.yml | 2 +- .github/workflows/release_staging.yml | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .github/actions/invalidate_master_cache/action.yml diff --git a/.github/actions/invalidate_master_cache/action.yml b/.github/actions/invalidate_master_cache/action.yml new file mode 100644 index 00000000..f568ba60 --- /dev/null +++ b/.github/actions/invalidate_master_cache/action.yml @@ -0,0 +1,11 @@ +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: ${{ build-master-cache-${{ hashFiles('./package-lock.json') }} diff --git a/.github/actions/npm_install_from_cache/action.yml b/.github/actions/npm_install_from_cache/action.yml index e2e0c2db..831a10eb 100644 --- a/.github/actions/npm_install_from_cache/action.yml +++ b/.github/actions/npm_install_from_cache/action.yml @@ -7,7 +7,7 @@ runs: id: cache-nodemodules uses: actions/cache/restore@v3 with: - key: v1-deps-{{ checksum "package-lock.json" }} + key: ${{ build-master-cache-${{ hashFiles('./package-lock.json') }} path: node_modules - name: Install npm dependencies if: steps.cache-nodemodules.outputs.cache-hit != 'true' diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index f4e2bf5f..9fc4699a 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -15,6 +15,8 @@ jobs: 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: From 6796ff40fd7e0114c90816afda5e345d896548a0 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 14:35:05 +0800 Subject: [PATCH 21/32] ci: replace codecov with coveralls --- .github/workflows/codecov.yml | 32 -------------------------------- .github/workflows/coveralls.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 32 deletions(-) delete mode 100755 .github/workflows/codecov.yml create mode 100755 .github/workflows/coveralls.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100755 index e08fe4af..00000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Codecov Workflow -on: - pull_request: - branches: - - '**' - push: - branches: - - master -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Use Node.js 16.x - uses: actions/setup-node@v1 - with: - node-version: 16.x - - name: install, bootstrap and make test coverage - run: | - npm ci - npm run build - npm run test - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.1.1 - with: - directory: ./coverage - fail_ci_if_error: false - files: ./coverage/lcov.info - name: codecov-umbrella - verbose: true diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml new file mode 100755 index 00000000..15d45d3f --- /dev/null +++ b/.github/workflows/coveralls.yml @@ -0,0 +1,26 @@ +name: Codecov Workflow +on: + pull_request: + branches: + - '**' + push: + branches: + - master +jobs: + build: + name: Build + runs-on: Runner_16cores_Deriv-app # 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 + - name: Coveralls + uses: coverallsapp/github-action@v2 From 30348bd12aed39a489751adcc540534c9b818140 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 14:37:06 +0800 Subject: [PATCH 22/32] chore: update workflow name --- .github/workflows/coveralls.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 15d45d3f..8664ba84 100755 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -1,4 +1,4 @@ -name: Codecov Workflow +name: Coveralls Workflow on: pull_request: branches: From a283dc387ef0fb0005aef9418cc4587ba8adab4e Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 14:40:31 +0800 Subject: [PATCH 23/32] chore: use ubuntu-latest as the runner --- .github/workflows/coveralls.yml | 2 +- .github/workflows/release_production.yml | 4 ++-- .github/workflows/release_staging.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 8664ba84..1c82bf66 100755 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -9,7 +9,7 @@ on: jobs: build: name: Build - runs-on: Runner_16cores_Deriv-app # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided + runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 155bf933..113d1a47 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -7,7 +7,7 @@ jobs: build_and_publish: name: Builds and Publishes to Cloudflare Pages Production environment: Production - runs-on: Runner_16cores_Deriv-app # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided + runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided steps: - name: Checkout uses: actions/checkout@v4 @@ -27,7 +27,7 @@ jobs: send_slack_notification: name: Send Slack Notification environment: Production - runs-on: Runner_16cores_Deriv-app # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided + runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided if: always() needs: - build_and_publish diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 9fc4699a..249df8bd 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -6,7 +6,7 @@ on: jobs: build_and_publish: name: Builds and Publishes to Cloudflare Pages Staging - runs-on: Runner_16cores_Deriv-app # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided + runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided environment: Staging steps: - name: Checkout From 065db58896be5853531a422f8ec94091a3539e27 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 14:49:27 +0800 Subject: [PATCH 24/32] chore: update path --- .github/actions/invalidate_master_cache/action.yml | 2 +- .github/actions/npm_install_from_cache/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/invalidate_master_cache/action.yml b/.github/actions/invalidate_master_cache/action.yml index f568ba60..aa433c53 100644 --- a/.github/actions/invalidate_master_cache/action.yml +++ b/.github/actions/invalidate_master_cache/action.yml @@ -8,4 +8,4 @@ runs: with: path: |- node_modules - key: ${{ build-master-cache-${{ hashFiles('./package-lock.json') }} + key: ${{ build-master-cache-${{ hashFiles('package-lock.json') }} diff --git a/.github/actions/npm_install_from_cache/action.yml b/.github/actions/npm_install_from_cache/action.yml index 831a10eb..9ce26cb7 100644 --- a/.github/actions/npm_install_from_cache/action.yml +++ b/.github/actions/npm_install_from_cache/action.yml @@ -7,7 +7,7 @@ runs: id: cache-nodemodules uses: actions/cache/restore@v3 with: - key: ${{ build-master-cache-${{ hashFiles('./package-lock.json') }} + key: ${{ build-master-cache-${{ hashFiles('package-lock.json') }} path: node_modules - name: Install npm dependencies if: steps.cache-nodemodules.outputs.cache-hit != 'true' From b02e7c7fd69d5b5125c0aad31c6960a045fdb302 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 14:55:09 +0800 Subject: [PATCH 25/32] chore: update key --- .github/actions/invalidate_master_cache/action.yml | 2 +- .github/actions/npm_install_from_cache/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/invalidate_master_cache/action.yml b/.github/actions/invalidate_master_cache/action.yml index aa433c53..48f92c98 100644 --- a/.github/actions/invalidate_master_cache/action.yml +++ b/.github/actions/invalidate_master_cache/action.yml @@ -8,4 +8,4 @@ runs: with: path: |- node_modules - key: ${{ build-master-cache-${{ hashFiles('package-lock.json') }} + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} diff --git a/.github/actions/npm_install_from_cache/action.yml b/.github/actions/npm_install_from_cache/action.yml index 9ce26cb7..4ddfdd64 100644 --- a/.github/actions/npm_install_from_cache/action.yml +++ b/.github/actions/npm_install_from_cache/action.yml @@ -7,8 +7,8 @@ runs: id: cache-nodemodules uses: actions/cache/restore@v3 with: - key: ${{ build-master-cache-${{ hashFiles('package-lock.json') }} 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 From f522cb9024674ebc29079b47a5b15749606f6e93 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 15:12:07 +0800 Subject: [PATCH 26/32] chore: add command to collect coverage --- .github/workflows/coveralls.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 1c82bf66..cc057a84 100755 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -21,6 +21,6 @@ jobs: uses: ./.github/actions/build - name: Run Tests run: | - npm run test + npm run test -- --collectCoverage - name: Coveralls uses: coverallsapp/github-action@v2 From 844a59151da94d89a15aca4b5ed70b1890c4ac6b Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Oct 2023 15:28:31 +0800 Subject: [PATCH 27/32] docs: update badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0066b5f3..ac33084e 100644 --- a/README.md +++ b/README.md @@ -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/actions/workflows/coveralls.yml/badge.svg)](https://coveralls.io/github/binary-com/deriv-api-docs/actions/workflows/coveralls.yml/badge.svg)