From c0c840d8ae650818862b95acf65f6d8268eb0eec Mon Sep 17 00:00:00 2001 From: Hasan Mobarak <126637868+hasan-deriv@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:58:32 +0800 Subject: [PATCH 1/3] Pr 00 workflow fix 3 (#7178) * chore: test workflow * chore: fixed preview url issue * chore: removed row eu workflow --- .github/workflows/generate-preview-link-eu.yml | 6 +++--- .github/workflows/generate-preview-link-row.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/generate-preview-link-eu.yml b/.github/workflows/generate-preview-link-eu.yml index 26d701491a8..7ccb2e63038 100644 --- a/.github/workflows/generate-preview-link-eu.yml +++ b/.github/workflows/generate-preview-link-eu.yml @@ -1,4 +1,4 @@ -name: Generate preview link for eu +name: Generate EU preview link on: pull_request_target: @@ -117,10 +117,10 @@ jobs: 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/') + branch=eutestlink-$(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://eutestlink-$branch.deriv-com-preview-links.pages.dev + preview_url=https://$branch.deriv-com-preview-links.pages.dev cat log.txt if grep -q "Deployment complete" log.txt; then echo "preview_url=$preview_url" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/generate-preview-link-row.yml b/.github/workflows/generate-preview-link-row.yml index 2a69b391a64..e297b14a411 100644 --- a/.github/workflows/generate-preview-link-row.yml +++ b/.github/workflows/generate-preview-link-row.yml @@ -1,4 +1,4 @@ -name: Generate preview link for ROW (Rest Of the World) +name: Generate ROW preview link on: pull_request_target: @@ -117,10 +117,10 @@ jobs: 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/') + branch=rowtestlink-$(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://row--$branch.deriv-com-preview-links.pages.dev + preview_url=https://$branch.deriv-com-preview-links.pages.dev cat log.txt if grep -q "Deployment complete" log.txt; then echo "preview_url=$preview_url" >> "$GITHUB_OUTPUT" From a641e8128d300352c52ed9a46740ce4f95c026f1 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Wed, 21 Feb 2024 15:09:28 +0800 Subject: [PATCH 2/3] chore: test workflow --- .../generate-preview-link-row-eu.yml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/generate-preview-link-row-eu.yml diff --git a/.github/workflows/generate-preview-link-row-eu.yml b/.github/workflows/generate-preview-link-row-eu.yml new file mode 100644 index 00000000000..6db2ad4220b --- /dev/null +++ b/.github/workflows/generate-preview-link-row-eu.yml @@ -0,0 +1,25 @@ +name: Generate preview link for ROW and EU + +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 + permissions: + checks: write + pull-requests: write + steps: + - name: Checkout to repo + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} \ No newline at end of file From bf0f3c38f52aadf47ea42e34c43bd6da68365b44 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Wed, 28 Feb 2024 12:04:23 +0800 Subject: [PATCH 3/3] chore: removed --- .../workflows/generate-preview-link-eu.yml | 181 ------------------ 1 file changed, 181 deletions(-) delete mode 100644 .github/workflows/generate-preview-link-eu.yml diff --git a/.github/workflows/generate-preview-link-eu.yml b/.github/workflows/generate-preview-link-eu.yml deleted file mode 100644 index 7ccb2e63038..00000000000 --- a/.github/workflows/generate-preview-link-eu.yml +++ /dev/null @@ -1,181 +0,0 @@ -name: Generate EU preview link - -on: - pull_request_target: - types: [opened, synchronize] - branches: - - '**' - -env: - NODE_OPTIONS: '--max-old-space-size=8192' - -concurrency: - group: cloudflare-eu-pages-build-${{github.head_ref}} - cancel-in-progress: true - -jobs: - build_eu_to_cloudflare_pages: - runs-on: Runner_16cores - permissions: - checks: write - pull-requests: write - 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@f43a0e5ff2bd294095638e18286ca9a3d1956744 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: 'Generate action link comment' - id: generate_action_url - uses: actions/github-script@ffc2c79a5b2490bd33e0a41c1de74b877714d736 - 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@efaaab3fd41a9c3de579aba759d2552635e590fd - with: - header: Cloudflare Pages EU 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@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 - - - 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@e12d46a63a90f2fae62d114769bbf2a179198b5c - with: - key: master-cache-public - restore-keys: | - master-cache-public-replica - path: | - sites/eu/.cache - sites/eu/public - - - name: Install Dependencies - uses: "./.github/actions/npm_install_from_cache" - - - 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: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=eutestlink-$(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 "Deployment complete" log.txt; then - echo "preview_url=$preview_url" >> "$GITHUB_OUTPUT" - echo $preview_url > .pr/PREVIEW_URL - else - echo "Deployment to Cloudflare Pages failed." - exit 1 - fi - - - name: 'Generate preview link comment' - if: success() - id: generate_preview_url - uses: actions/github-script@ffc2c79a5b2490bd33e0a41c1de74b877714d736 - 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 |', - '| :--- | :------ |', - `| **EU 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@ffc2c79a5b2490bd33e0a41c1de74b877714d736 - 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@efaaab3fd41a9c3de579aba759d2552635e590fd - 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@82c141cc518b40d92cc801eee768e7aafc9c2fa2 - with: - name: 'pr-${{github.run_id}}' - path: .pr