Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vercel testlink workflow setup #70

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/generate_testlink.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deriv App ID Generator

permissions:
actions: write
checks: write
contents: write
deployments: write
pull-requests: write
statuses: write
Comment on lines +3 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Consider reducing the workflow permissions to only those actually required

The workflow appears to only need 'pull-requests' and possibly 'contents' permissions. Following the principle of least privilege, consider removing unused permissions to reduce security risk.

Suggested change
permissions:
actions: write
checks: write
contents: write
deployments: write
pull-requests: write
statuses: write
permissions:
contents: write
pull-requests: write


on:
issue_comment:
types: [created, edited]
push:

jobs:
generate_app_id:
timeout-minutes: 5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider increasing the timeout duration to accommodate potential API delays and retries

With 5 retries configured for the app ID generation, 5 minutes might be insufficient if there are network delays or service issues. Consider increasing to 10-15 minutes to prevent timeout failures.

Suggested change
timeout-minutes: 5
timeout-minutes: 15

runs-on: ubuntu-latest
steps:
- name: Capture Vercel preview URL
id: vercel_preview_url
uses: binary-com/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_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.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
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.GITHUB_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 }}`

<details>
<summary>Click here to copy & paste above information.</summary>

```
- **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 }}`
```
</details>

- 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
Loading