forked from deriv-com/SmartCharts
-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (105 loc) · 4.77 KB
/
generate_preview_link.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Generate preview link
permissions:
actions: write
checks: write
contents: write
deployments: write
pull-requests: write
statuses: write
on:
pull_request_target:
types: [opened, synchronize]
env:
HEAD_REF: ${{ github.head_ref }}
concurrency:
group: cloudflare-pages-build-"$HEAD_REF"
cancel-in-progress: true
jobs:
build_and_deploy_preview_link:
runs-on: Ubuntu-latest
steps:
- name: Retrieve pull request
id: pr_information
run: |
echo "username=$(cat .pr/USERNAME)" >> $GITHUB_OUTPUT
echo "issue_number=$(cat .pr/ISSUE_NUMBER)" >> $GITHUB_OUTPUT
echo "branch_name=$(cat .pr/BRANCHNAME)" >> $GITHUB_OUTPUT
- name: Post preview build comment
id: post_preview_build_comment
uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1'
with:
issue_number: ${{steps.pr_information.outputs.issue_number}}
head_sha: ${{github.event.pull_request.head.sha}}
- name: Checkout SmartCharts
uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master'
with:
repository: ${{steps.pr_information.outputs.username}}/SmartCharts
path: SmartCharts
ref: ${{steps.pr_information.outputs.branch_name}}
alternate_repository: 'binary-com/SmartCharts'
alternate_ref: master
- name: Checkout deriv-app
uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master'
with:
repository: ${{steps.pr_information.outputs.username}}/deriv-app
path: deriv-app
ref: ${{steps.pr_information.outputs.branch_name}}
alternate_repository: 'binary-com/deriv-app'
alternate_ref: master
- name: Custom flutter-chart
uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master'
with:
repository: ${{steps.pr_information.outputs.username}}/flutter-chart
path: flutter-chart
ref: ${{steps.pr_information.outputs.branch_name}}
alternate_repository: 'regentmarkets/flutter-chart'
alternate_ref: fe-changes
- name: Setup Node
uses: actions/setup-node@44c9c187283081e4e88b54b0efad9e9d468165a4
with:
node-version: 18.x
- name: Setup deriv-app
run: cd deriv-app && npm install && npm run bootstrap
- name: Remove @deriv-charts in deriv-app
run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist
- name: Setup SmartCharts
run: cd SmartCharts && npm install
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.10.6'
channel: 'stable'
cache: true
- name: Build flutter
run: |
cd SmartCharts/chart_app
flutter pub get
flutter build web --web-renderer html --release
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Build SmartCharts
run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist
- name: Run Tests
run: cd SmartCharts && npm run test
- name: Build deriv-app
run: cd deriv-app && npm run build:all
- name: Setup Node
uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a
with:
node-version: 20
- name: Publish to CF pages branch
id: publish_to_pages_branch
uses: 'deriv-com/shared-actions/.github/actions/publish_to_pages_branch@v1'
with:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }}
project_name: 'smartcharts-preview'
branch_name: 'pr-${{github.event.number}}'
output_dir: deriv-app/packages/core/dist
- name: 'Generate preview link comment'
if: always() && steps.post_preview_build_comment.outcome == 'success'
uses: 'deriv-com/shared-actions/.github/actions/post_preview_link_comment@v1'
with:
issue_number: ${{github.event.number}}
check_run_id: ${{steps.post_preview_build_comment.outputs.check_run_id}}
preview_url: ${{steps.publish_to_pages_branch.outputs.cf_pages_url}}
status: ${{job.status}}