-
Notifications
You must be signed in to change notification settings - Fork 55
197 lines (172 loc) · 7.06 KB
/
web.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Build Web
on:
workflow_dispatch:
env:
owner: ObsidianLabs
own_components: eth-components
share_components: electron-components
project_build: eth
project_project: eth
project_name: Black IDE
project_build_script: yarn && PUBLIC_URL=/ CDN=true yarn build:react
enable_auth: true
premium_editor: ../premium-editor
cos_bucket: ethereum-ide-1303090311
cos_region: ap-singapore
dns_path: https://ide.black/
CLOUDFRONT_DISTRIBUTION_ID: E28UBPK9Z0N99E
jobs:
build-info:
runs-on: ubuntu-18.04
steps:
- name: Get ${{ env.project_name }}'s build info
id: build-info
shell: bash
run: |
echo ::set-output name=BRANCH::${GITHUB_REF##*/}
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo ::set-output name=NEW_RELEASE::true
echo ::set-output name=BRANCH::master
echo "project_build_script=yarn && yarn dist" >> $GITHUB_ENV
fi
outputs:
branch: ${{ steps.build-info.outputs.BRANCH }}
new_release: ${{ steps.build-info.outputs.NEW_RELEASE}}
# Build and release
build:
needs: build-info
runs-on: ubuntu-18.04
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Development Branch Detected
if: ${{ needs.build-info.outputs.branch != 'master'}}
run: |
echo "Deploying ${{ github.ref }} branch"
echo "cos_bucket=ethereum-ide-test-1303090311" >> $GITHUB_ENV
echo "dns_path=https://eth-test.ide.black/" >> $GITHUB_ENV
echo "CLOUDFRONT_DISTRIBUTION_ID=E19AK26SFJYOK4" >> $GITHUB_ENV
echo "project_build_script=yarn && REACT_APP_ENV=development yarn build:web-staging" >> $GITHUB_ENV
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 16
- name: Checkout ${{ env.share_components }}
uses: actions/checkout@v2
with:
repository: ${{ env.owner }}/${{ env.share_components }}
ref: ${{ needs.build-info.outputs.branch }}
path: ${{ env.share_components }}
token: ${{ secrets.obsidians_token }}
- name: Checkout ${{ env.own_components }}
uses: actions/checkout@v2
with:
repository: ${{ env.owner }}/${{ env.own_components }}
ref: ${{ needs.build-info.outputs.branch }}
path: ${{ env.own_components }}
token: ${{ secrets.obsidians_token }}
- name: Checkout Premium Editor
uses: actions/checkout@v2
with:
repository: ${{ env.owner }}/premium-editor
ref: ${{ needs.build-info.outputs.branch }}
path: premium-editor
token: ${{ secrets.obsidians_token }}
- name: Checkout ${{ env.project_name }}
uses: actions/checkout@v2
with:
ref: ${{ needs.build-info.outputs.branch }}
path: studio
- name: Extract version
id: extract_version
uses: Saionaro/extract-package-version@v1.1.1
with:
path: studio
- name: Install ${{ env.share_components }} submodule
working-directory: ${{ env.share_components }}
run: git submodule update --init
- name: Install ${{ env.share_components }} dependencies
working-directory: ${{ env.share_components }}
run: yarn
- name: Build ${{ env.share_components }}
working-directory: ${{ env.share_components }}
run: yarn build
- name: Install ${{ env.own_components }} submodule
working-directory: ${{ env.own_components }}
run: git submodule update --init
- name: Install ${{ env.own_components }} dependencies
working-directory: ${{ env.own_components }}
run: yarn
- name: Build ${{ env.own_components }}
working-directory: ${{ env.own_components }}
run: yarn build
- name: Install Premium Editor dependencies
working-directory: premium-editor
run: yarn
- name: Build Premium Editor
working-directory: premium-editor
run: yarn build
- name: Build ${{ env.project_name }}
uses: ObsidianLabs/studio-build-action@master
with:
build: ${{ env.project_build }}
project: ${{ env.project_project }}
project_name: ${{ env.project_name }}
build_script: ${{ env.project_build_script }}
working-directory: ./studio
enable_auth: ${{ env.enable_auth }}
fontawesome_token: ${{ secrets.fontawesome_token }}
mac_certs: ${{ secrets.certs }}
mac_certs_password: ${{ secrets.certs_password }}
windows_certs: ${{ secrets.certs }}
windows_certs_password: ${{ secrets.certs_password }}
react_app_mixpanel_token: ${{ secrets.react_app_mixpanel_token }}
premium_editor: ${{ env.premium_editor }}
github_token: ${{ github.token }}
build_id: ${{ github.run_id }}
build_time: ${{ github.updated_at }}
commit_id: ${{ github.sha }}
- name: Create a placeholder for COS
run: echo cos > .placeholder
- name: Upload ${{ env.project_name }} to COS
uses: zkqiang/tencent-cos-action@v0.1.0
with:
args: upload .placeholder / && delete -r -f / && upload -r studio/build/ /
secret_id: ${{ secrets.tencent_cloud_secretid }}
secret_key: ${{ secrets.tencent_cloud_secretkey }}
bucket: ${{ env.cos_bucket }}
region: ${{ env.cos_region }}
- name: Flush ${{ env.project_name }} CDN
uses: TencentCloud/cli-action@v1
with:
secret_id: ${{ secrets.tencent_cloud_secretId }}
secret_key: ${{ secrets.tencent_cloud_secretKey }}
# Tencent Cloud product region
region: ${{ env.cos_region }}
# Tencent Cloud CLI commands. Mult commands seperate by `&&`
commands: 'cdn PurgePathCache --cli-unfold-argument --Paths ${{ env.dns_path }} --FlushType flush'
# Data format of command output. Available values are `json`, `table`, `text`. Default is `json`
output_format: 'json'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.CF_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.CF_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Invalidate Cloudfront CDN
run: aws cloudfront create-invalidation --distribution-id=${{ env.CLOUDFRONT_DISTRIBUTION_ID }} --paths '/*'
send-notification:
needs: [build, build-info]
runs-on: ubuntu-18.04
if: success()
steps:
- name: Discord Notification
uses: ObsidianLabs/github-discord-bot@master
with:
discord_webhook: ${{ secrets.DISCORD_WEBHOOK }}
branch: ${{ needs.build-info.outputs.branch }}
version: ${{ needs.build.outputs.version }}
client: 'web'
commit_id: ${{ github.sha }}
runner_id: ${{ github.run_id }}
test_server_api_url: ${{ secrets.TEST_SERVER_API_URL }}