From 706ec96edc2b5c293aa72602ef17aa8b007a7a78 Mon Sep 17 00:00:00 2001 From: "Ali(Ako) Hosseini" Date: Thu, 7 Dec 2023 16:06:55 +0800 Subject: [PATCH 1/2] ci: add version.txt file to build folder --- .github/actions/versioning/action.yml | 5 ++++- .github/workflows/release_production.yml | 1 + .github/workflows/release_staging.yml | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/actions/versioning/action.yml b/.github/actions/versioning/action.yml index 1a1f6c07..405d1172 100644 --- a/.github/actions/versioning/action.yml +++ b/.github/actions/versioning/action.yml @@ -5,9 +5,12 @@ inputs: description: Release Type required: false default: staging + RELEASE_TAG: + description: Release Tag + required: true runs: using: composite steps: - name: Tag build - run: echo "${{ inputs.RELEASE_TYPE }} $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version + run: echo "${{ inputs.RELEASE_TYPE }}--GITHUB_REF:${{ inputs.RELEASE_TAG }}--DATE:$(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version.txt shell: bash diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index b8c7e23b..cbc80af2 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -24,6 +24,7 @@ jobs: - name: Versioning uses: ./.github/actions/versioning with: + RELEASE_TAG: ${{ github.ref_name }} RELEASE_TYPE: production - name: Extract version id: extract_version diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 10f2bcf8..72cd005e 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -21,6 +21,11 @@ jobs: uses: ./.github/actions/build with: NODE_ENV: staging + - name: Versioning + uses: ./.github/actions/versioning + with: + RELEASE_TAG: ${{ github.sha }} + RELEASE_TYPE: staging - name: Publish to Cloudflare Pages Staging uses: ./.github/actions/publish_to_pages_staging with: From 8521bffb52da276393cf4fab7073c3ec907f446c Mon Sep 17 00:00:00 2001 From: "Ali(Ako) Hosseini" Date: Thu, 7 Dec 2023 16:09:16 +0800 Subject: [PATCH 2/2] ci: remove circleci config as its not needed anymore --- .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.*/