From c51cdb971be573c3686a7cb61878deaf6f79a6cc Mon Sep 17 00:00:00 2001 From: Habib Deriv <88178645+habib-deriv@users.noreply.github.com> Date: Sun, 4 Feb 2024 20:10:51 +0800 Subject: [PATCH] Revert "chore: added actions for row and eu build (#6976)" This reverts commit 692ce21ae5198db75d36d32f7705539ac2e5e8b2. --- .../generate-preview-link-for-eu.yml | 193 ------------------ .../generate-preview-link-for-row.yml | 193 ------------------ 2 files changed, 386 deletions(-) delete mode 100644 .github/workflows/generate-preview-link-for-eu.yml delete mode 100644 .github/workflows/generate-preview-link-for-row.yml diff --git a/.github/workflows/generate-preview-link-for-eu.yml b/.github/workflows/generate-preview-link-for-eu.yml deleted file mode 100644 index cbe4b344c1a..00000000000 --- a/.github/workflows/generate-preview-link-for-eu.yml +++ /dev/null @@ -1,193 +0,0 @@ -name: Generate Eu preview link - -permissions: - actions: write - checks: write - contents: write - deployments: write - pull-requests: write - statuses: write - -on: - pull_request_target: - types: [opened, synchronize] - branches: - - '**' - -env: - NODE_OPTIONS: '--max-old-space-size=8192' - -concurrency: - group: cloudflare-pages-build-${{github.head_ref}} - cancel-in-progress: true - -jobs: - build_to_cloudflare_pages: - runs-on: Ubuntu-latest - steps: - - name: Verify user - uses: 'deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1' - with: - username: ${{github.event.pull_request.user.login}} - token: ${{ secrets.PREVIEW_LINK_TOKEN }} - - - name: Checkout to repo - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: 'Generate action link comment' - id: generate_action_url - uses: actions/github-script@v3 - with: - github-token: ${{ github.token }} - script: | - const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}" - const comment = [ - '| Name | Result |', - '| :--- | :------ |', - `| **Eu Build status** | Building 🔨 |`, - `| **Eu Action URL** | [Visit Action](${action_url}) |`, - '' - ].join('\n') - core.setOutput("comment", comment); - - - name: Post Cloudflare Pages Preview comment - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: Cloudflare Pages Preview Comment - number: ${{github.event.pull_request.user.login}} - message: ${{steps.generate_action_url.outputs.comment}} - recreate: true - - - name: Setup node - uses: actions/setup-node@v2 - - - name: Create npmrc file - shell: bash - run: echo "@deriv-com:registry=https://npm.pkg.github.com" >> .npmrc - - - name: Setup install read-only token for deriv-com org - shell: bash - run: echo '//npm.pkg.github.com/:_authToken=${{ secrets.READ_DERIV_COM_ORG_PACKAGES }}' >> .npmrc - - - name: Get build output from master cache - uses: actions/cache/restore@v3 - with: - key: master-cache-public - restore-keys: | - master-cache-public-replica - path: | - .cache - public - - name: Get cached dependencies - id: cache-npm - uses: actions/cache/restore@v3 - with: - path: node_modules - key: npm-${{ hashFiles('**/package-lock.json') }} - - - name: Install dependencies - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - run: npm ci - - - name: Build project - id: build-project - env: - GATSBY_ENV: staging - GATSBY_GEuTHBOOK_CLIENT_KEY: ${{ secrets.GATSBY_GEuTHBOOK_CLIENT_KEY }} - GATSBY_GEuTHBOOK_DECRYPTION_KEY: ${{ secrets.GATSBY_GEuTHBOOK_DECRYPTION_KEY }} - GATSBY_RUDDERSTACK_STAGING_KEY: ${{ secrets.GATSBY_RUDDERSTACK_STAGING_KEY }} - GATSBY_RUDDERSTACK_PRODUCTION_KEY: ${{ secrets.GATSBY_RUDDERSTACK_PRODUCTION_KEY }} - GATSBY_STRAPI_TOKEN: ${{ secrets.GATSBY_STRAPI_TOKEN }} - GATSBY_GOOGLE_TAG_MANAGER_TRACKING_ID: ${{ secrets.GATSBY_GOOGLE_TAG_MANAGER_TRACKING_ID }} - GATSBY_TRUSTPILOT_API_KEY: ${{ secrets.GATSBY_TRUSTPILOT_API_KEY }} - GATSBY_HOTJAR_ID: ${{ secrets.GATSBY_HOTJAR_ID }} - - run: npm run build:eu - - - name: Retrieve PR information - env: - EVENT_NUMBER: ${{ github.event.number }} - EVENT_USERNAME: ${{ github.event.pull_request.user.login }} - HEAD_REF: ${{ github.head_ref }} - run: | - mkdir -p .pr - echo "$EVENT_NUMBER" > .pr/NR - echo "$EVENT_USERNAME" > .pr/USERNAME - echo "$HEAD_REF" > .pr/BRANCHNAME - - - name: Publish to Cloudflare Pages - id: publish-to-pages - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }} - HEAD_BRANCH: ${{ github.head_ref }} - run: | - echo "Installing Wrangler CLI" - npm i -g wrangler - echo "Deploying build to Cloudflare Pages" - directory='sites/eu/public' - projectName='deriv-com-preview-links' - branch=$(echo "$HEAD_BRANCH" | head -c 20 | sed 's/[\/_\.]/-/g; s/[^a-zA-Z0-9]$/1/') - cf_preview_url=$(wrangler pages deploy $directory --project-name=$projectName --branch=$branch > log.txt 2>&1; echo $?) - echo "------" - preview_url=https://$branch.deriv-com-preview-links.pages.dev - cat log.txt - if grep -q "Eu Deployment complete" log.txt; then - echo "preview_url=$preview_url" >> "$GITHUB_OUTPUT" - echo $preview_url > .pr/PREVIEW_URL - else - echo "Eu Deployment to Cloudflare Pages failed." - exit 1 - fi - - - name: 'Generate Eu preview link comment' - if: success() - id: generate_preview_url - uses: actions/github-script@v3 - with: - github-token: ${{ github.token }} - script: | - const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}" - const preview_url = "${{steps.publish-to-pages.outputs.preview_url}}" - const comment = [ - `**Preview Link**: ${preview_url}`, - '| Name | Result |', - '| :--- | :------ |', - `| **Build status** | Completed ✅ |`, - `| **Eu Preview URL** | [Visit Preview](${preview_url}) |`, - `| **Eu Action URL** | [Visit Action](${action_url}) |`, - '' - ].join('\n') - core.setOutput("comment", comment); - - name: 'Generate failure comment' - if: failure() - id: generate_failure_comment - uses: actions/github-script@v3 - with: - github-token: ${{ github.token }} - script: | - const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}" - const comment = [ - '| Name | Result |', - '| :--- | :------ |', - `| **Eu Build status** | Failed ❌ |`, - `| **Eu Action URL** | [Visit Action](${action_url}) |`, - '' - ].join('\n') - core.setOutput("comment", comment); - - name: Post Cloudflare Pages Preview comment - if: success() || failure() - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: Cloudflare Pages Preview Comment - number: ${{github.event.number}} - message: ${{steps.generate_preview_url.outputs.comment || steps.generate_failure_comment.outputs.comment }} - recreate: true - - - name: Upload PR information to artifact - uses: actions/upload-artifact@v2 - with: - name: 'pr-${{github.run_id}}' - path: .pr diff --git a/.github/workflows/generate-preview-link-for-row.yml b/.github/workflows/generate-preview-link-for-row.yml deleted file mode 100644 index 2f6de60292d..00000000000 --- a/.github/workflows/generate-preview-link-for-row.yml +++ /dev/null @@ -1,193 +0,0 @@ -name: Generate Row preview link - -permissions: - actions: write - checks: write - contents: write - deployments: write - pull-requests: write - statuses: write - -on: - pull_request_target: - types: [opened, synchronize] - branches: - - '**' - -env: - NODE_OPTIONS: '--max-old-space-size=8192' - -concurrency: - group: cloudflare-pages-build-${{github.head_ref}} - cancel-in-progress: true - -jobs: - build_to_cloudflare_pages: - runs-on: Ubuntu-latest - steps: - - name: Verify user - uses: 'deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1' - with: - username: ${{github.event.pull_request.user.login}} - token: ${{ secrets.PREVIEW_LINK_TOKEN }} - - - name: Checkout to repo - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: 'Generate action link comment' - id: generate_action_url - uses: actions/github-script@v3 - with: - github-token: ${{ github.token }} - script: | - const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}" - const comment = [ - '| Name | Result |', - '| :--- | :------ |', - `| **Row Build status** | Building 🔨 |`, - `| **Row Action URL** | [Visit Action](${action_url}) |`, - '' - ].join('\n') - core.setOutput("comment", comment); - - - name: Post Cloudflare Pages Preview comment - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: Cloudflare Pages Preview Comment - number: ${{github.event.pull_request.user.login}} - message: ${{steps.generate_action_url.outputs.comment}} - recreate: true - - - name: Setup node - uses: actions/setup-node@v2 - - - name: Create npmrc file - shell: bash - run: echo "@deriv-com:registry=https://npm.pkg.github.com" >> .npmrc - - - name: Setup install read-only token for deriv-com org - shell: bash - run: echo '//npm.pkg.github.com/:_authToken=${{ secrets.READ_DERIV_COM_ORG_PACKAGES }}' >> .npmrc - - - name: Get build output from master cache - uses: actions/cache/restore@v3 - with: - key: master-cache-public - restore-keys: | - master-cache-public-replica - path: | - .cache - public - - name: Get cached dependencies - id: cache-npm - uses: actions/cache/restore@v3 - with: - path: node_modules - key: npm-${{ hashFiles('**/package-lock.json') }} - - - name: Install dependencies - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - run: npm ci - - - name: Build project - id: build-project - env: - GATSBY_ENV: staging - GATSBY_GROWTHBOOK_CLIENT_KEY: ${{ secrets.GATSBY_GROWTHBOOK_CLIENT_KEY }} - GATSBY_GROWTHBOOK_DECRYPTION_KEY: ${{ secrets.GATSBY_GROWTHBOOK_DECRYPTION_KEY }} - GATSBY_RUDDERSTACK_STAGING_KEY: ${{ secrets.GATSBY_RUDDERSTACK_STAGING_KEY }} - GATSBY_RUDDERSTACK_PRODUCTION_KEY: ${{ secrets.GATSBY_RUDDERSTACK_PRODUCTION_KEY }} - GATSBY_STRAPI_TOKEN: ${{ secrets.GATSBY_STRAPI_TOKEN }} - GATSBY_GOOGLE_TAG_MANAGER_TRACKING_ID: ${{ secrets.GATSBY_GOOGLE_TAG_MANAGER_TRACKING_ID }} - GATSBY_TRUSTPILOT_API_KEY: ${{ secrets.GATSBY_TRUSTPILOT_API_KEY }} - GATSBY_HOTJAR_ID: ${{ secrets.GATSBY_HOTJAR_ID }} - - run: npm run build:row - - - name: Retrieve PR information - env: - EVENT_NUMBER: ${{ github.event.number }} - EVENT_USERNAME: ${{ github.event.pull_request.user.login }} - HEAD_REF: ${{ github.head_ref }} - run: | - mkdir -p .pr - echo "$EVENT_NUMBER" > .pr/NR - echo "$EVENT_USERNAME" > .pr/USERNAME - echo "$HEAD_REF" > .pr/BRANCHNAME - - - name: Publish to Cloudflare Pages - id: publish-to-pages - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }} - HEAD_BRANCH: ${{ github.head_ref }} - run: | - echo "Installing Wrangler CLI" - npm i -g wrangler - echo "Deploying build to Cloudflare Pages" - directory='sites/row/public' - projectName='deriv-com-preview-links' - branch=$(echo "$HEAD_BRANCH" | head -c 20 | sed 's/[\/_\.]/-/g; s/[^a-zA-Z0-9]$/1/') - cf_preview_url=$(wrangler pages deploy $directory --project-name=$projectName --branch=$branch > log.txt 2>&1; echo $?) - echo "------" - preview_url=https://$branch.deriv-com-preview-links.pages.dev - cat log.txt - if grep -q "Row Deployment complete" log.txt; then - echo "preview_url=$preview_url" >> "$GITHUB_OUTPUT" - echo $preview_url > .pr/PREVIEW_URL - else - echo "Row Deployment to Cloudflare Pages failed." - exit 1 - fi - - - name: 'Generate Row preview link comment' - if: success() - id: generate_preview_url - uses: actions/github-script@v3 - with: - github-token: ${{ github.token }} - script: | - const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}" - const preview_url = "${{steps.publish-to-pages.outputs.preview_url}}" - const comment = [ - `**Preview Link**: ${preview_url}`, - '| Name | Result |', - '| :--- | :------ |', - `| **Build status** | Completed ✅ |`, - `| **Row Preview URL** | [Visit Preview](${preview_url}) |`, - `| **Row Action URL** | [Visit Action](${action_url}) |`, - '' - ].join('\n') - core.setOutput("comment", comment); - - name: 'Generate failure comment' - if: failure() - id: generate_failure_comment - uses: actions/github-script@v3 - with: - github-token: ${{ github.token }} - script: | - const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}" - const comment = [ - '| Name | Result |', - '| :--- | :------ |', - `| **Row Build status** | Failed ❌ |`, - `| **Row Action URL** | [Visit Action](${action_url}) |`, - '' - ].join('\n') - core.setOutput("comment", comment); - - name: Post Cloudflare Pages Preview comment - if: success() || failure() - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: Cloudflare Pages Preview Comment - number: ${{github.event.number}} - message: ${{steps.generate_preview_url.outputs.comment || steps.generate_failure_comment.outputs.comment }} - recreate: true - - - name: Upload PR information to artifact - uses: actions/upload-artifact@v2 - with: - name: 'pr-${{github.run_id}}' - path: .pr