From fabb01a3908ae8875782d4fcf7347aadc434551b Mon Sep 17 00:00:00 2001 From: Aum Bhatt Date: Wed, 8 Jan 2025 15:30:48 +0400 Subject: [PATCH 1/5] ci: yml for testlinks --- .github/workflows/generate_testlink.yml | 71 +++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/generate_testlink.yml diff --git a/.github/workflows/generate_testlink.yml b/.github/workflows/generate_testlink.yml new file mode 100644 index 0000000..45d30c3 --- /dev/null +++ b/.github/workflows/generate_testlink.yml @@ -0,0 +1,71 @@ +name: Deriv App ID Generator + +permissions: + actions: write + checks: write + contents: write + deployments: write + pull-requests: write + statuses: write + +on: + issue_comment: + types: [edited] + +jobs: + generate_app_id: + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - name: Capture Vercel preview URL + id: vercel_preview_url + uses: binary-com/vercel-preview-url-action@v1.0.5 + with: + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + preview_url_regexp: \[Visit Preview\]\((.*?.sx)\) + - name: Generate Deriv App ID for deployment Preview URL + id: generate_app_id + uses: deriv-com/deriv-app-id-action@v1 + with: + DERIV_API_TOKEN: ${{ secrets.DERIV_API_TOKEN }} + DERIV_APP_ID: ${{ secrets.DERIV_APP_ID }} + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + max_retries: 5 + vercel_preview_url: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }} + - name: Comment on pull request with App ID and URLs + id: sticky_comment_on_pr + if: steps.generate_app_id.outputs.should_post_comment + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 + with: + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + header: deriv-app-id-action + number: ${{github.event.issue.number}} + message: | + A production App ID was automatically generated for this PR. ([log](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})) + + - **PR**: [${{ steps.generate_app_id.outputs.pr_url }}](${{ steps.generate_app_id.outputs.pr_url }}) + - **URLs**: + - **w/ App ID + Server**: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}?qa_server=red.derivws.com&app_id=${{ steps.generate_app_id.outputs.app_id }} + - **Original**: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }} + - **App ID**: `${{ steps.generate_app_id.outputs.app_id }}` + +
+ Click here to copy & paste above information. + + ``` + - **PR**: [${{ steps.generate_app_id.outputs.pr_url }}](${{ steps.generate_app_id.outputs.pr_url }}) + - **URLs**: + - **w/ App ID + Server**: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}?qa_server=red.derivws.com&app_id=${{ steps.generate_app_id.outputs.app_id }} + - **Original**: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }} + - **App ID**: `${{ steps.generate_app_id.outputs.app_id }}` + ``` +
+ + - name: Store generated URL in artifact + run: echo "HOME_URL=${{ steps.vercel_preview_url.outputs.vercel_preview_url }}?qa_server=red.derivws.com&app_id=${{ steps.generate_app_id.outputs.app_id }}" >> ${{ github.workspace }}/url.txt + - name: Upload artifact + uses: actions/upload-artifact@master + with: + name: generated_url + path: ${{ github.workspace }}/url.txt + retention-days: 1 \ No newline at end of file From ba68a93496b44494751eaf691667fad24f8c24be Mon Sep 17 00:00:00 2001 From: Aum Bhatt Date: Thu, 9 Jan 2025 11:14:09 +0400 Subject: [PATCH 2/5] ci: change personal access token secret --- .github/workflows/generate_testlink.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate_testlink.yml b/.github/workflows/generate_testlink.yml index 45d30c3..b8804dd 100644 --- a/.github/workflows/generate_testlink.yml +++ b/.github/workflows/generate_testlink.yml @@ -21,7 +21,7 @@ jobs: id: vercel_preview_url uses: binary-com/vercel-preview-url-action@v1.0.5 with: - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} preview_url_regexp: \[Visit Preview\]\((.*?.sx)\) - name: Generate Deriv App ID for deployment Preview URL id: generate_app_id @@ -29,7 +29,7 @@ jobs: with: DERIV_API_TOKEN: ${{ secrets.DERIV_API_TOKEN }} DERIV_APP_ID: ${{ secrets.DERIV_APP_ID }} - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} max_retries: 5 vercel_preview_url: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }} - name: Comment on pull request with App ID and URLs @@ -37,7 +37,7 @@ jobs: if: steps.generate_app_id.outputs.should_post_comment uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 with: - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} header: deriv-app-id-action number: ${{github.event.issue.number}} message: | From ca21cb47b1b5091dbe2e49ae49aeee27e56839a8 Mon Sep 17 00:00:00 2001 From: Aum Bhatt Date: Thu, 9 Jan 2025 11:33:35 +0400 Subject: [PATCH 3/5] ci: changed comment trigger to created --- .github/workflows/generate_testlink.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate_testlink.yml b/.github/workflows/generate_testlink.yml index b8804dd..0893808 100644 --- a/.github/workflows/generate_testlink.yml +++ b/.github/workflows/generate_testlink.yml @@ -10,7 +10,7 @@ permissions: on: issue_comment: - types: [edited] + types: [created] jobs: generate_app_id: From cb64bdf466708930fa8fd684cbcd536948ef3aad Mon Sep 17 00:00:00 2001 From: Aum Bhatt Date: Thu, 9 Jan 2025 11:36:55 +0400 Subject: [PATCH 4/5] ci: add edited event --- .github/workflows/generate_testlink.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate_testlink.yml b/.github/workflows/generate_testlink.yml index 0893808..b804632 100644 --- a/.github/workflows/generate_testlink.yml +++ b/.github/workflows/generate_testlink.yml @@ -10,7 +10,7 @@ permissions: on: issue_comment: - types: [created] + types: [created, edited] jobs: generate_app_id: From 2e1dbf9c653a0481362c89128e85c1e42e0f3380 Mon Sep 17 00:00:00 2001 From: Aum Bhatt Date: Thu, 9 Jan 2025 11:41:17 +0400 Subject: [PATCH 5/5] ci: add push event --- .github/workflows/generate_testlink.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/generate_testlink.yml b/.github/workflows/generate_testlink.yml index b804632..e154005 100644 --- a/.github/workflows/generate_testlink.yml +++ b/.github/workflows/generate_testlink.yml @@ -11,6 +11,7 @@ permissions: on: issue_comment: types: [created, edited] + push: jobs: generate_app_id: