Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Konstantinos/DPROD-3000/[FE] Revamp Regulatory Information page (ROW) #6940

Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 0 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@
"pattern": "features/components/templates/layout",
"group": "parent",
"position": "after"
},
{
"pattern": "features/components/quill/quill-layout",
"group": "parent",
"position": "after"
}
],
"newlines-between": "never"
Expand Down
71 changes: 44 additions & 27 deletions .github/workflows/generate-preview-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,42 @@ permissions:
statuses: write

on:
pull_request_target:
types: [opened, synchronize]
branches:
- '**'
workflow_run:
workflows: ['Pre-generate preview link']
types:
- completed

env:
NODE_OPTIONS: '--max-old-space-size=8192'

concurrency:
group: cloudflare-pages-build-${{github.head_ref}}
group: cloudflare-pages-build-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true

jobs:
build_to_cloudflare_pages:
runs-on: Ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
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 }}
ref: ${{ github.event.workflow_run.head_sha }}
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: 'pr-${{ github.event.workflow_run.id }}'
path: .pr

- name: Retrieve pull request
id: pr_information
run: |
echo "issue_number=$(cat .pr/NR)" >> $GITHUB_OUTPUT

- name: 'Generate action link comment'
id: generate_action_url
Expand All @@ -51,15 +61,33 @@ jobs:
''
].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}}
number: ${{steps.pr_information.outputs.issue_number}}
message: ${{steps.generate_action_url.outputs.comment}}
recreate: true

- name: Verify user organization
id: verify_user_organization
run: |
echo "Verifying user's organization..."
user=$(cat .pr/USERNAME)
response=$(curl -s -L \
-w "%{http_code}" \
-o /dev/null -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/binary-com/memberships/$user")

if [ $response != "200" ]; then
echo "User is not a member of binary-com organization."
exit 1
else
echo "User is a member of binary-com organization."
echo "Proceeding to build and deploy for the pull request: https://github.com/binary-com/deriv-com/pull/$(cat ./NR)"
fi
- name: Setup node
uses: actions/setup-node@v2

Expand Down Expand Up @@ -106,23 +134,12 @@ jobs:

run: npm run build

- 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 }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
echo "Installing Wrangler CLI"
npm i -g wrangler
Expand Down Expand Up @@ -182,7 +199,7 @@ jobs:
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Cloudflare Pages Preview Comment
number: ${{github.event.number}}
number: ${{steps.pr_information.outputs.issue_number}}
message: ${{steps.generate_preview_url.outputs.comment || steps.generate_failure_comment.outputs.comment }}
recreate: true

Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/pre-generate-preview-link.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Pre-generate preview link

permissions:
pull-requests: write

on:
pull_request:
types: [opened, synchronize]
concurrency:
group: 'cloudflare-pages-verify-${{ github.head_ref }}'
cancel-in-progress: true

jobs:
verify_pull_request:
runs-on: Ubuntu-latest
steps:
- 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: Upload PR information to artifact
env:
RUN_ID: ${{ github.run_id }}
uses: actions/upload-artifact@v2
with:
name: 'pr-${{ env.RUN_ID }}'
path: pr/
Loading
Loading