From cf8f83109c23eadf1989a993e805c30df4650d3d Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Mon, 16 Oct 2023 12:00:10 +0400 Subject: [PATCH 01/10] build: to migrate from circleci to github workflows --- .github/actions/build/action.yml | 8 +++ .github/actions/notify_slack/action.yml | 37 ++++++++++++++ .github/actions/npm_install/action.yml | 9 ++++ .../publish_to_pages_production/action.yml | 22 ++++++++ .../publish_to_pages_staging/action.yml | 22 ++++++++ .github/actions/tag/action.yml | 21 ++++++++ .github/workflows/release_production.yml | 50 ++++++++++++++++++ .github/workflows/release_staging.yml | 51 +++++++++++++++++++ 8 files changed, 220 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/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/tag/action.yml create mode 100644 .github/workflows/release_production.yml create mode 100644 .github/workflows/release_staging.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 00000000..56efb7f7 --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,8 @@ +name: build +description: Build for release +runs: + steps: + - name: Building Application + 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..3f71f6e4 --- /dev/null +++ b/.github/actions/notify_slack/action.yml @@ -0,0 +1,37 @@ +name: notify slack +description: Notify Slack +inputs: + SLACK_WEBHOOK: + 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 sindabad with version *'"${{ inputs.version }}"'*" + }' \ + $SLACK_WEBHOOK + 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 sindabad with version *'"${{ inputs.version }}"'*" + }' \ + $SLACK_WEBHOOK + shell: bash \ No newline at end of file diff --git a/.github/actions/npm_install/action.yml b/.github/actions/npm_install/action.yml new file mode 100644 index 00000000..da912ced --- /dev/null +++ b/.github/actions/npm_install/action.yml @@ -0,0 +1,9 @@ +name: npm_install +description: Install NPM packages +runs: + steps: + - name: Install npm packages + run: |- + npm ci + npm run format + 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..0c8dc18c --- /dev/null +++ b/.github/actions/publish_to_pages_production/action.yml @@ -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 wrangler@3.1.0 + cd packages/core + npx wrangler pages publish . --project-name=sinbad-pages --branch=main + echo "New website - http://cf-pages-sinbad.deriv.com" + shell: bash 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..2b67c1f8 --- /dev/null +++ b/.github/actions/publish_to_pages_staging/action.yml @@ -0,0 +1,22 @@ +name: publish_to_pages_staging +description: Publish 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 wrangler@3.1.0 + cd public + npx wrangler pages publish . --project-name=sinbad-pages --branch=staging + echo "New staging website - http://staging.cf-pages-sinbad.deriv.com" + shell: bash diff --git a/.github/actions/tag/action.yml b/.github/actions/tag/action.yml new file mode 100644 index 00000000..e56cc1b2 --- /dev/null +++ b/.github/actions/tag/action.yml @@ -0,0 +1,21 @@ +name: versioning +description: Versioning +inputs: + RELEASE_TYPE: + description: Release Type + required: false +outputs: + version: + description: Version +runs: + using: composite + + steps: + - name: Set Version + id: set_version + run: | + current_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + version="${{ inputs.RELEASE_TYPE }}-GH_Run#:${{ github.run_number }}-Date:$current_date" + echo "Setting version to: $version" + echo "version=$version" >> $GITHUB_ENV + shell: bash diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml new file mode 100644 index 00000000..e449d7b8 --- /dev/null +++ b/.github/workflows/release_production.yml @@ -0,0 +1,50 @@ +name: Sinbad Production Workflow +on: + push: + tags: + - production_* +jobs: + build_test_and_publish: + name: Build, Test and Publish to Cloudflare Pages Production + environment: Production + runs-on: Runner_16cores_Deriv-app + outputs: + RELEASE_VERSION: ${{ steps.extract_version.outputs.RELEASE_VERSION }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: NPM Install + uses: "./.github/actions/npm_install" + - name: Build + uses: "./.github/actions/build" + with: + NODE_ENV: production + - name: Versioning + uses: "./.github/actions/tag" + with: + release_type: production + - name: Extract version + id: extract_version + run: echo "RELEASE_VERSION=${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 + runs-on: Runner_16cores_Deriv-app + environment: Production + if: always() + needs: [build_test_and_publish] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Send Slack Notification + uses: "./.github/actions/send_slack_notifications" + with: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} + status: ${{ env.WORKFLOW_CONCLUSION }} + release_type: Production + version: ${{ needs.build_test_and_publish.outputs.RELEASE_VERSION}} diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml new file mode 100644 index 00000000..58259bfd --- /dev/null +++ b/.github/workflows/release_staging.yml @@ -0,0 +1,51 @@ +name: Sinbad Staging Workflow +on: + push: + branches: + - master + +jobs: + build_test_and_publish: + name: Build, Test and Publish to Cloudflare Staging + runs-on: Runner_16cores_Deriv-app + environment: Staging + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Tag + uses: "./.github/actions/tag" + - name: Npm Install + uses: "./.github/actions/npm_install" + - name: Build + uses: "./.github/actions/build" + with: + NODE_ENV: staging + - name: Versioning + uses: "./.github/actions/tag" + with: + release_type: staging + - name: Extract version + id: extract_version + run: echo "RELEASE_VERSION=${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 }} + + send_slack_notification: + name: Send Slack notification + runs-on: Runner_16cores_Deriv-app + environment: Staging + if: always() + needs: [build_test_and_publish] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Send Slack Notification + uses: "./.github/actions/send_slack_notifications" + with: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} + status: ${{ env.WORKFLOW_CONCLUSION }} + release_type: Staging + version: ${{ needs.build_test_and_publish.outputs.RELEASE_VERSION}} \ No newline at end of file From 58fcd968fc3d76fe7b682efa84b1053b898de059 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Fri, 20 Oct 2023 13:49:26 +0400 Subject: [PATCH 02/10] build: to migrate from circleci to github workflows --- .github/actions/build/action.yml | 3 +-- .github/actions/tests/action.yml | 7 +++++++ .github/workflows/release_production.yml | 6 ++++-- .github/workflows/release_staging.yml | 23 ++++------------------- 4 files changed, 16 insertions(+), 23 deletions(-) create mode 100644 .github/actions/tests/action.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 56efb7f7..b97c69d0 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -3,6 +3,5 @@ description: Build for release runs: steps: - name: Building Application - run: |- - npm run build + run: npm run build shell: bash \ No newline at end of file diff --git a/.github/actions/tests/action.yml b/.github/actions/tests/action.yml new file mode 100644 index 00000000..058178e0 --- /dev/null +++ b/.github/actions/tests/action.yml @@ -0,0 +1,7 @@ +name: run_test +description: Run tests after creating PR +runs: + steps: + - name: Run Tests + run: npm run test + shell: bash \ No newline at end of file diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index e449d7b8..89e09b2b 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -7,7 +7,7 @@ jobs: build_test_and_publish: name: Build, Test and Publish to Cloudflare Pages Production environment: Production - runs-on: Runner_16cores_Deriv-app + runs-on: ubuntu-latest outputs: RELEASE_VERSION: ${{ steps.extract_version.outputs.RELEASE_VERSION }} steps: @@ -19,6 +19,8 @@ jobs: uses: "./.github/actions/build" with: NODE_ENV: production + - name: Run Test + uses: "./.github/actions/tests" - name: Versioning uses: "./.github/actions/tag" with: @@ -34,7 +36,7 @@ jobs: send_slack_notification: name: Send Slack notification - runs-on: Runner_16cores_Deriv-app + runs-on: ubuntu-latest environment: Production if: always() needs: [build_test_and_publish] diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 58259bfd..b51ddcab 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -7,7 +7,7 @@ on: jobs: build_test_and_publish: name: Build, Test and Publish to Cloudflare Staging - runs-on: Runner_16cores_Deriv-app + runs-on: ubuntu-latest environment: Staging steps: - name: Checkout @@ -20,6 +20,8 @@ jobs: uses: "./.github/actions/build" with: NODE_ENV: staging + - name: Run Test + uses: "./.github/actions/tests" - name: Versioning uses: "./.github/actions/tag" with: @@ -31,21 +33,4 @@ jobs: uses: "./.github/actions/publish_to_pages_staging" with: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - - send_slack_notification: - name: Send Slack notification - runs-on: Runner_16cores_Deriv-app - environment: Staging - if: always() - needs: [build_test_and_publish] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Send Slack Notification - uses: "./.github/actions/send_slack_notifications" - with: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} - status: ${{ env.WORKFLOW_CONCLUSION }} - release_type: Staging - version: ${{ needs.build_test_and_publish.outputs.RELEASE_VERSION}} \ No newline at end of file + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} \ No newline at end of file From 1275804e2ad3fcf9ba56bf3ba48fa1250509e7b7 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:26:13 +0400 Subject: [PATCH 03/10] build: moved test from action to workflow --- .github/actions/tests/action.yml | 7 ------- .github/workflows/release_production.yml | 2 -- .github/workflows/release_staging.yml | 2 -- .github/workflows/test.yml | 0 4 files changed, 11 deletions(-) delete mode 100644 .github/actions/tests/action.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/actions/tests/action.yml b/.github/actions/tests/action.yml deleted file mode 100644 index 058178e0..00000000 --- a/.github/actions/tests/action.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: run_test -description: Run tests after creating PR -runs: - steps: - - name: Run Tests - run: npm run test - shell: bash \ No newline at end of file diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 89e09b2b..fede9c1f 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -19,8 +19,6 @@ jobs: uses: "./.github/actions/build" with: NODE_ENV: production - - name: Run Test - uses: "./.github/actions/tests" - name: Versioning uses: "./.github/actions/tag" with: diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index b51ddcab..55d30d25 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -20,8 +20,6 @@ jobs: uses: "./.github/actions/build" with: NODE_ENV: staging - - name: Run Test - uses: "./.github/actions/tests" - name: Versioning uses: "./.github/actions/tag" with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..e69de29b From b0d496ac81e732175c5339373fe050238fb57568 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:04:02 +0400 Subject: [PATCH 04/10] build: added test.yml file --- .github/workflows/test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e69de29b..90bebcee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -0,0 +1,15 @@ +name: Sinbad Test Workflow +on: + pull_request: + branches: + - master +jobs: + build_and_test: + name: Build And Test + runs-on: ubuntu_latest + environment: Development + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Npm Install + uses: "./.github/actions/npm_install" From e0208f9d4beae8f4eab0ae0682adbf9714662365 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:42:42 +0400 Subject: [PATCH 05/10] refactor: to fix EOF errors --- .github/actions/build/action.yml | 2 +- .github/actions/notify_slack/action.yml | 2 +- .github/actions/npm_install/action.yml | 2 +- .github/workflows/release_staging.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index b97c69d0..e1cbd504 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -4,4 +4,4 @@ runs: steps: - name: Building Application 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 3f71f6e4..dc55e2ba 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -34,4 +34,4 @@ runs: "text": "'"${{ inputs.release_type }}"' Release failed for sindabad with version *'"${{ inputs.version }}"'*" }' \ $SLACK_WEBHOOK - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/actions/npm_install/action.yml b/.github/actions/npm_install/action.yml index da912ced..a9a1e8fe 100644 --- a/.github/actions/npm_install/action.yml +++ b/.github/actions/npm_install/action.yml @@ -6,4 +6,4 @@ runs: run: |- npm ci npm run format - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 55d30d25..7b0127d9 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -31,4 +31,4 @@ jobs: uses: "./.github/actions/publish_to_pages_staging" with: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} \ No newline at end of file + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} From 51c378a614888986742fa9689e76d6d7ea679d75 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:51:41 +0400 Subject: [PATCH 06/10] refactor: to remove version from staging env --- .github/actions/notify_slack/action.yml | 8 ++++---- .github/workflows/release_staging.yml | 7 ------- .github/workflows/test.yml | 2 ++ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml index dc55e2ba..6cb8e055 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -22,16 +22,16 @@ runs: run: |- curl -X POST -H 'Content-type: application/json' \ --data '{ - "text": "'"${{ inputs.release_type }}"' Release succeeded for sindabad with version *'"${{ inputs.version }}"'*" + "text": "'"${{ inputs.release_type }}"' Release succeeded for Sindabad with version *'"${{ inputs.version }}"'*" }' \ - $SLACK_WEBHOOK + ${{ 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 sindabad with version *'"${{ inputs.version }}"'*" + "text": "'"${{ inputs.release_type }}"' Release failed for Sindabad with version *'"${{ inputs.version }}"'*" }' \ - $SLACK_WEBHOOK + ${{ inputs.SLACK_WEBHOOK_URL }} shell: bash diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 7b0127d9..e4c74475 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -20,13 +20,6 @@ jobs: uses: "./.github/actions/build" with: NODE_ENV: staging - - name: Versioning - uses: "./.github/actions/tag" - with: - release_type: staging - - name: Extract version - id: extract_version - run: echo "RELEASE_VERSION=${version}" >> $GITHUB_OUTPUT - name: Publish to Cloudflare Pages Staging uses: "./.github/actions/publish_to_pages_staging" with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 90bebcee..5aa130ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,3 +13,5 @@ jobs: uses: actions/checkout@v4 - name: Npm Install uses: "./.github/actions/npm_install" + - name: Build + uses: "./.github/actions/build" From 503dd3075e695d08de775c6458026843250ede64 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Tue, 24 Oct 2023 09:36:53 +0400 Subject: [PATCH 07/10] refactor: to remove version from staging env --- .github/actions/build/action.yml | 2 +- .github/actions/notify_slack/action.yml | 2 +- .github/actions/tag/action.yml | 2 +- .github/workflows/release_production.yml | 2 +- .github/workflows/release_staging.yml | 2 +- .github/workflows/test.yml | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index e1cbd504..dd4fdaf2 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,4 +1,4 @@ -name: build +name: Build description: Build for release runs: steps: diff --git a/.github/actions/notify_slack/action.yml b/.github/actions/notify_slack/action.yml index 6cb8e055..66cd5b60 100644 --- a/.github/actions/notify_slack/action.yml +++ b/.github/actions/notify_slack/action.yml @@ -1,4 +1,4 @@ -name: notify slack +name: Notify slack description: Notify Slack inputs: SLACK_WEBHOOK: diff --git a/.github/actions/tag/action.yml b/.github/actions/tag/action.yml index e56cc1b2..d4cb18ea 100644 --- a/.github/actions/tag/action.yml +++ b/.github/actions/tag/action.yml @@ -1,4 +1,4 @@ -name: versioning +name: Versioning description: Versioning inputs: RELEASE_TYPE: diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index fede9c1f..398bb15f 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: NPM Install + - name: Install npm packages uses: "./.github/actions/npm_install" - name: Build uses: "./.github/actions/build" diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index e4c74475..829048bf 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v4 - name: Tag uses: "./.github/actions/tag" - - name: Npm Install + - name: Install npm packages uses: "./.github/actions/npm_install" - name: Build uses: "./.github/actions/build" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5aa130ee..e2cb0969 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,13 +5,13 @@ on: - master jobs: build_and_test: - name: Build And Test + name: Build and Test runs-on: ubuntu_latest environment: Development steps: - name: Checkout uses: actions/checkout@v4 - - name: Npm Install + - name: Install npm packages uses: "./.github/actions/npm_install" - name: Build uses: "./.github/actions/build" From 2258faa12d59d35535e0e50b30e59f21a0061d19 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:59:49 +0400 Subject: [PATCH 08/10] refactor: to remove environment from workflows --- .github/workflows/release_production.yml | 2 -- .github/workflows/release_staging.yml | 1 - .github/workflows/test.yml | 1 - 3 files changed, 4 deletions(-) diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 398bb15f..9248243f 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -6,7 +6,6 @@ on: jobs: build_test_and_publish: name: Build, Test and Publish to Cloudflare Pages Production - environment: Production runs-on: ubuntu-latest outputs: RELEASE_VERSION: ${{ steps.extract_version.outputs.RELEASE_VERSION }} @@ -35,7 +34,6 @@ jobs: send_slack_notification: name: Send Slack notification runs-on: ubuntu-latest - environment: Production if: always() needs: [build_test_and_publish] steps: diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index 829048bf..ca822ce6 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -8,7 +8,6 @@ jobs: build_test_and_publish: name: Build, Test and Publish to Cloudflare Staging runs-on: ubuntu-latest - environment: Staging steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e2cb0969..fc1f3e59 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,6 @@ jobs: build_and_test: name: Build and Test runs-on: ubuntu_latest - environment: Development steps: - name: Checkout uses: actions/checkout@v4 From 3b1034f30324e1e6c6d70df3225cedb3d9779a24 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:44:01 +0400 Subject: [PATCH 09/10] refactor: to add node from cache --- .github/actions/npm_install/action.yml | 9 --------- .../actions/npm_install_from_cache/action.yml | 17 +++++++++++++++++ .github/workflows/release_production.yml | 2 +- .github/workflows/release_staging.yml | 2 +- .github/workflows/test.yml | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) delete mode 100644 .github/actions/npm_install/action.yml create mode 100644 .github/actions/npm_install_from_cache/action.yml diff --git a/.github/actions/npm_install/action.yml b/.github/actions/npm_install/action.yml deleted file mode 100644 index a9a1e8fe..00000000 --- a/.github/actions/npm_install/action.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: npm_install -description: Install NPM packages -runs: - steps: - - name: Install npm packages - run: |- - npm ci - npm run format - shell: bash 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..f96eeb4e --- /dev/null +++ b/.github/actions/npm_install_from_cache/action.yml @@ -0,0 +1,17 @@ +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 ci + npm run format + shell: bash diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 9248243f..74c61d58 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Install npm packages - uses: "./.github/actions/npm_install" + uses: "./.github/actions/npm_install_from_cache" - name: Build uses: "./.github/actions/build" with: diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index ca822ce6..5562e7bb 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -14,7 +14,7 @@ jobs: - name: Tag uses: "./.github/actions/tag" - name: Install npm packages - uses: "./.github/actions/npm_install" + uses: "./.github/actions/npm_install_from_cache" - name: Build uses: "./.github/actions/build" with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc1f3e59..ced11a65 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Install npm packages - uses: "./.github/actions/npm_install" + uses: "./.github/actions/npm_install_from_cache" - name: Build uses: "./.github/actions/build" From 97e75cb5d5a00650d3974b6c5ebf21afd83ea1a0 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:38:20 +0400 Subject: [PATCH 10/10] Update .github/workflows/test.yml Co-authored-by: Ali(Ako) Hosseini --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ced11a65..aefc471d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: jobs: build_and_test: name: Build and Test - runs-on: ubuntu_latest + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4