-
Notifications
You must be signed in to change notification settings - Fork 187
195 lines (178 loc) · 7.75 KB
/
deploy.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
name: deploy
on:
push:
branches:
- production
- preprod
- mainnet
- develop
workflow_dispatch:
jobs:
set_environment:
name: Set Environment
if: contains(github.ref, 'production') || contains(github.ref, 'preprod') || contains(github.ref, 'mainnet')
outputs:
env_name: ${{ steps.setenv.outputs.env_name }}
dnslink_subdomain: ${{ steps.setdnslink.outputs.dnslink_subdomain }}
runs-on: ubuntu-latest
steps:
- name: Set "environment" var
id: setenv
run: |
if [[ "${GITHUB_REF#refs/heads/}" == "production" || "${GITHUB_REF#refs/heads/}" == "preprod" ]]
then
echo "env_name=production" >> $GITHUB_OUTPUT
else
echo "env_name=mainnet" >> $GITHUB_OUTPUT
fi
- name: Set dnslink var
id: setdnslink
run: |
if [[ "${GITHUB_REF#refs/heads/}" == "production" ]]
then
echo "dnslink_subdomain=_dnslink.app" >> $GITHUB_OUTPUT
else
echo "dnslink_subdomain=_dnslink.${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
fi
call-workflow1:
name: Publish NPM Core Package If Necessary
uses: ./.github/workflows/npm_publish_core.yml
with:
environment: production
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
call-workflow2:
needs: call-workflow1
name: Publish NPM SDK Package If Necessary
uses: ./.github/workflows/npm_publish_sdk.yml
with:
environment: production
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
bump_version:
name: Bump Github Release Version
if: contains(github.ref, 'production')
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.github_tag_action.outputs.new_tag }}
changelog: ${{ steps.github_tag_action.outputs.changelog }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Bump version and push tag
id: github_tag_action
uses: mathieudutour/github-tag-action@331898d5052eedac9b15fec867b5ba66ebf9b692
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: production
default_bump: patch
build:
if: contains(github.ref, 'production') || contains(github.ref, 'preprod') || contains(github.ref, 'mainnet')
name: Build and Deploy
runs-on: ubuntu-latest
needs: [set_environment, call-workflow2]
outputs:
hash: ${{ steps.upload.outputs.hash }}
environment:
name: ${{ needs.set_environment.outputs.env_name }}
env:
ENV_NAME: ${{ needs.set_environment.outputs.env_name }}
RECORD_NAME: ${{ needs.set_environment.outputs.dnslink_subdomain }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
defaults:
run:
working-directory: ./packages/frontend
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Log set env vars
run: |
echo "ENV_NAME=${ENV_NAME}"
echo "RECORD_NAME=${RECORD_NAME}"
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14.17.6
registry-url: https://registry.npmjs.org
- name: Update npm
run: npm install -g npm@latest
- name: Install node dependencies
run: npm install
- name: Build the frontend app
env:
PUBLIC_URL: ${{ secrets.PUBLIC_URL }}
REACT_APP_NETWORK: ${{ secrets.REACT_APP_NETWORK }}
REACT_APP_IPFS_BUILD: ${{ secrets.REACT_APP_IPFS_BUILD }}
REACT_APP_BNC_DAPP_ID: ${{ secrets.REACT_APP_BNC_DAPP_ID }}
REACT_APP_ENABLED_CHAINS: ${{ secrets.REACT_APP_ENABLED_CHAINS }}
REACT_APP_ENABLED_TOKENS: ${{ secrets.REACT_APP_ENABLED_TOKENS }}
REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }}
REACT_APP_DISABLED_ROUTES: ${{ secrets.REACT_APP_DISABLED_ROUTES }}
REACT_APP_WARNING_ROUTES: ${{ secrets.REACT_APP_WARNING_ROUTES }}
REACT_APP_DISABLE_NATIVE_ASSET_TRANSFERS: ${{ secrets.REACT_APP_DISABLE_NATIVE_ASSET_TRANSFERS }}
REACT_APP_DISABLED_ROUTES_NO_LIQUIDITY_WARNING_MESSAGE: ${{ secrets.REACT_APP_DISABLED_ROUTES_NO_LIQUIDITY_WARNING_MESSAGE }}
REACT_APP_SHOW_BANNER_MESSAGE: ${{ secrets.REACT_APP_SHOW_BANNER_MESSAGE }}
REACT_APP_BLOCKLIST_ENABLED: ${{ secrets.REACT_APP_BLOCKLIST_ENABLED }}
run: npm run build
- name: Write commit file
uses: "DamianReeves/write-file-action@a432935930b2e351ec2d2792fc220717b656ec1c"
with:
path: packages/frontend/build/cachebust
write-mode: overwrite
contents: ${{ github.sha }}
- name: Pin to IPFS on Pinata
id: upload
uses: anantaramdas/ipfs-pinata-deploy-action@9f9c3b42b5d360352c4b768d98aff1309d62faa0
with:
pin-name: Hop ${{ github.sha }}
path: './packages/frontend/build'
verbose: true
pinata-api-key: ${{ secrets.IPFS_DEPLOY_PINATA__API_KEY }}
pinata-secret-api-key: ${{ secrets.IPFS_DEPLOY_PINATA__SECRET_API_KEY }}
- name: Update CloudFlare DNS with new IPFS hash
env:
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
RECORD_DOMAIN: 'hop.exchange'
RECORD_NAME: ${{ needs.set_environment.outputs.dnslink_subdomain }}
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
uses: textileio/cloudflare-update-dnslink@30414a408191218c8259e932ebdf4cbb7c652fe8
with:
cid: ${{ steps.upload.outputs.hash }}
- name: Convert CIDv0 to CIDv1
id: convert_cidv0
uses: uniswap/[email protected]
with:
cidv0: ${{ steps.upload.outputs.hash }}
- name: Set short sha
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Create GitHub Release
id: create_release
if: contains(github.ref, 'production')
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.bump_version.outputs.new_tag || steps.vars.outputs.sha_short }}
release_name: Release ${{ needs.bump_version.outputs.new_tag || steps.vars.outputs.sha_short }}
body: |
IPFS hash of the deployment:
- CIDv0: `${{ steps.upload.outputs.hash }}`
- CIDv1: `${{ steps.convert_cidv0.outputs.cidv1 }}`
The latest release is always accessible via our alias to the Cloudflare IPFS gateway at [app.hop.exchange](https://app.hop.exchange).
You can also access the Hop Interface directly from an IPFS gateway.
**Note**: The Hop interface uses [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to remember your settings, such as slippage tolerance.
**You should always use an IPFS gateway that enforces origin separation**, or our alias to the latest release at [app.hop.exchange](https://app.hop.exchange).
Your Hop settings are never remembered across different URLs.
IPFS gateways:
- https://${{ steps.convert_cidv0.outputs.cidv1 }}.ipfs.cf-ipfs.com/
- https://${{ steps.convert_cidv0.outputs.cidv1 }}.ipfs.dweb.link/
- https://hop.mypinata.cloud/ipfs/${{ steps.upload.outputs.hash }}/
- https://gateway.pinata.cloud/ipfs/${{ steps.upload.outputs.hash }}/
- https://cloudflare-ipfs.com/ipfs/${{ steps.upload.outputs.hash }}/
- https://gateway.ipfs.io/ipfs/${{ steps.upload.outputs.hash }}/
- https://crustwebsites.net/ipfs/${{ steps.upload.outputs.hash }}/
- [ipfs://${{ steps.upload.outputs.hash }}/](ipfs://${{ steps.upload.outputs.hash }}/)
- https://hop.eth.limo/
- https://hop.eth.link/
${{ needs.bump_version.outputs.changelog }}