Skip to content

Commit 905abca

Browse files
[DTRA]Ahmad/DTRA-791/Smartcharts preview links (#1487)
* chore: setup preview link generation * chore: remove unused workflows * chore: add PAT * chore: remove deriv-app deploy * new changes * generate link * testing test link * test link * test link * test link * testing link * testing link * testing link * testing link * testing link * testing link * testing link * testing link * testing link * testing link * testing link * testing link * testing link * testing link * add concurrency * replaxing names * Update .github/CODEOWNERS * Update .github/workflows/generate_preview_link.yml * Update .github/workflows/generate_preview_link.yml * Update .github/workflows/generate_preview_link.yml * github action ecosystem added --------- Co-authored-by: balakrishna-binary <[email protected]> Co-authored-by: balakrishna-deriv <[email protected]>
1 parent 96a7360 commit 905abca

File tree

8 files changed

+212
-88
lines changed

8 files changed

+212
-88
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Configuration of code ownership and review approvals for the binary-com/deriv-app repo.
2+
#
3+
# More info: https://help.github.com/articles/about-codeowners/
4+
#
5+
6+
* @binary-com/write-admin-smartcharts
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Checkout
2+
3+
inputs:
4+
fetch-depth:
5+
default: 1
6+
required: false
7+
type: number
8+
path:
9+
required: false
10+
type: string
11+
repository:
12+
default: ${{ github.repository }}
13+
required: false
14+
type: string
15+
ref:
16+
required: false
17+
type: string
18+
alternate_repository:
19+
required: false
20+
type: string
21+
alternate_ref:
22+
required: false
23+
type: string
24+
token:
25+
default: ${{ github.token }}
26+
required: false
27+
type: string
28+
29+
outputs:
30+
ref_exists:
31+
description: 'Specifies whether the ref exists or not'
32+
value: ${{ steps.repo.outputs.ref-exists }}
33+
34+
runs:
35+
using: composite
36+
37+
steps:
38+
- id: repo
39+
shell: bash
40+
env:
41+
GH_TOKEN: ${{ inputs.token }}
42+
run: |
43+
if git ls-remote --heads --quiet --exit-code https://${{ inputs.token }}@github.com/${{ inputs.repository }}.git ${{ inputs.ref }}
44+
then
45+
echo "::notice::Checkout: ${{ inputs.repository }} using ${{ inputs.ref }}"
46+
echo "ref-exists=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "::notice::Checkout: ${{ inputs.repository }} does not have ref ${{ inputs.ref }} (fallback to ${{ inputs.alternate_ref }})"
49+
echo "ref-exists=false" >> $GITHUB_OUTPUT
50+
fi
51+
52+
- if: steps.repo.outputs.ref-exists == 'true'
53+
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
54+
with:
55+
fetch-depth: ${{ inputs.fetch-depth }}
56+
path: ${{ inputs.path }}
57+
repository: ${{ inputs.repository }}
58+
ref: ${{ inputs.ref }}
59+
token: ${{ inputs.token }}
60+
61+
- if: steps.repo.outputs.ref-exists == 'false'
62+
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
63+
with:
64+
fetch-depth: ${{ inputs.fetch-depth }}
65+
path: ${{ inputs.path }}
66+
repository: ${{ inputs.alternate_repository }}
67+
ref: ${{ inputs.alternate_ref }}
68+
token: ${{ inputs.token }}

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "daily"

.github/workflows/generate_and_push_deriv_charts.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
steps:
1010
- name: Setup node and npm
1111
id: step1
12-
uses: actions/setup-node@v2
12+
uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a
1313
with:
1414
node-version: '18'
1515
check-latest: true
@@ -18,7 +18,7 @@ jobs:
1818
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
1919
- name: Checkout repo
2020
id: step2
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
2222
with:
2323
fetch-depth: 1
2424
ref: master
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Generate preview link
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize]
6+
7+
concurrency:
8+
group: cloudflare-pages-build-${{ github.head_ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build_and_deploy_preview_link:
13+
runs-on: Ubuntu-latest
14+
permissions:
15+
checks: write
16+
pull-requests: write
17+
steps:
18+
- name: Verify user
19+
uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1"
20+
with:
21+
username: ${{github.event.pull_request.user.login}}
22+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
23+
24+
- name: Post preview build comment
25+
id: post_preview_build_comment
26+
uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1'
27+
with:
28+
issue_number: ${{github.event.number}}
29+
head_sha: ${{github.event.pull_request.head.sha}}
30+
31+
- name: Checkout SmartCharts
32+
uses: 'binary-com/SmartCharts/.github/actions/checkout@master'
33+
with:
34+
repository: ${{github.event.pull_request.user.login}}/SmartCharts
35+
path: SmartCharts
36+
ref: ${{github.head_ref}}
37+
alternate_repository: 'binary-com/SmartCharts'
38+
alternate_ref: master
39+
40+
- name: Checkout deriv-app
41+
uses: 'binary-com/SmartCharts/.github/actions/checkout@master'
42+
with:
43+
repository: ${{github.event.pull_request.user.login}}/deriv-app
44+
path: deriv-app
45+
ref: ${{github.head_ref}}
46+
alternate_repository: 'binary-com/deriv-app'
47+
alternate_ref: master
48+
49+
- name: Custom flutter-chart
50+
uses: 'binary-com/SmartCharts/.github/actions/checkout@master'
51+
with:
52+
repository: ${{github.event.pull_request.user.login}}/flutter-chart
53+
path: flutter-chart
54+
ref: ${{github.head_ref}}
55+
alternate_repository: 'regentmarkets/flutter-chart'
56+
alternate_ref: fe-changes
57+
token: ${{ secrets.REPO_READ_TOKEN }}
58+
59+
- uses: subosito/flutter-action@v2
60+
with:
61+
flutter-version: '3.10.6'
62+
channel: 'stable'
63+
cache: true
64+
65+
- name: Add SSH key
66+
run: |
67+
mkdir -p ~/.ssh
68+
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/github_action_key
69+
chmod 600 ~/.ssh/github_action_key
70+
71+
- name: Build flutter
72+
env:
73+
GIT_SSH_COMMAND: 'ssh -i ~/.ssh/github_action_key'
74+
run: |
75+
cd SmartCharts/chart_app
76+
flutter pub get
77+
flutter build web --web-renderer html --release
78+
79+
- name: Setup Node
80+
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8
81+
with:
82+
node-version: 18.x
83+
84+
- name: Setup deriv-app
85+
run: cd deriv-app && npm install && npm run bootstrap
86+
87+
- name: Remove @deriv-charts in deriv-app
88+
run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist
89+
90+
- name: Setup SmartCharts
91+
run: cd SmartCharts && npm install
92+
93+
- name: Build SmartCharts
94+
run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist
95+
96+
- name: Run Tests
97+
run: cd SmartCharts && npm run test
98+
99+
- name: Build deriv-app
100+
env:
101+
NODE_ENV: 'production'
102+
run: cd deriv-app && npm run build:all
103+
104+
- name: Setup Node
105+
uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a
106+
with:
107+
node-version: 20
108+
109+
- name: Publish to CF pages branch
110+
id: publish_to_pages_branch
111+
uses: 'deriv-com/shared-actions/.github/actions/publish_to_pages_branch@v1'
112+
with:
113+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }}
114+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }}
115+
project_name: 'smartcharts-preview'
116+
branch_name: 'pr-${{github.event.number}}'
117+
output_dir: deriv-app/packages/core/dist
118+
119+
- name: 'Generate preview link comment'
120+
if: always() && steps.post_preview_build_comment.outcome == 'success'
121+
uses: 'deriv-com/shared-actions/.github/actions/post_preview_link_comment@v1'
122+
with:
123+
issue_number: ${{github.event.number}}
124+
check_run_id: ${{steps.post_preview_build_comment.outputs.check_run_id}}
125+
preview_url: ${{steps.publish_to_pages_branch.outputs.cf_pages_url}}
126+
status: ${{job.status}}

.github/workflows/release-automation.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/tag-release.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

scripts/deriv-app-deploy.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)