Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Ali / add automatic test link and app id generation #6582

Merged
Merged
Show file tree
Hide file tree
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
58 changes: 58 additions & 0 deletions .github/workflows/generate_app_id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Binary App ID Generator

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@v0.0.3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Binary App ID for deployment Preview URL
id: generate_app_id
uses: ali-fs/binary-app-id-action@master
with:
BINARY_API_TOKEN: ${{ secrets.BINARY_API_TOKEN }}
BINARY_APP_ID: ${{ secrets.BINARY_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@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: binary-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 }}/en/logged_inws.html?qa_server=frontend.binaryws.com&app_id=${{ steps.generate_app_id.outputs.app_id }}
- **Original**: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}/en/logged_inws.html
- **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 }}/en/logged_inws.html?qa_server=frontend.binaryws.com&app_id=${{ steps.generate_app_id.outputs.app_id }}
- **Original**: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}/en/logged_inws.html
- **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=frontend.binaryws.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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"livereload": "sudo -p 'enter password for sudo:' grunt livereload",
"serve": "sudo -p 'enter password for sudo:' grunt serve",
"start": "sudo -p 'enter password for sudo:' grunt start",
"eslint": "eslint --fix \"src/**/*.jsx\" src/"
"eslint": "eslint --fix \"src/**/*.jsx\" src/",
"build": "grunt releaseci --production"
},
"repository": {
"type": "git",
Expand Down
12 changes: 12 additions & 0 deletions src/javascript/app/base/binary_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const BinaryLoader = (() => {

localizeForLang(urlLang());

checkAppidAndQAserver();

Page.showNotificationOutdatedBrowser();

Client.init();
Expand All @@ -50,6 +52,16 @@ const BinaryLoader = (() => {

};

const checkAppidAndQAserver = () => {
const urlParams = new URLSearchParams(window.location.search);
const qa_server = urlParams.get('qa_server');
const app_id = urlParams.get('app_id');
if (qa_server && app_id) {
localStorage.setItem('config.server_url', qa_server);
localStorage.setItem('config.app_id', app_id);
}
};

const beforeContentChange = () => {
if (active_script) {
BinarySocket.removeOnDisconnect();
Expand Down