-
Notifications
You must be signed in to change notification settings - Fork 17
144 lines (132 loc) · 4.75 KB
/
web.build.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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: CI Web Vault
on:
push:
branches:
- develop
- master
tags:
- '*'
pull_request:
branches:
- develop
- master
jobs:
web-build:
runs-on: ubuntu-latest
env:
REACT_APP_NET_TYPE_ID: ${{matrix.network.id}}
REACT_APP_HAVEN_DIRECT_HOST: ${{matrix.network.url}}
strategy:
matrix:
network:
- id: 0
url: "https://nodes.havenprotocol.org:443"
name: "mainnet"
- id: 1
url: "https://nodes-testnet.havenprotocol.org:443"
name: "testnet"
- id: 2
url: "https://nodes-stagenet.havenprotocol.org:443"
name: "stagenet"
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install client dependencies
working-directory: client
run: |
git config --global url."https://".insteadOf git://
npm install
- name: Install latest wallet core
working-directory: client
run: |
npm install haven-wallet-core@latest --save
- name: Copy wallet core to root folder
working-directory: client
run: |
npm run copy-haven-core
- name: Audit client dependencies
working-directory: client
run: |
npm audit fix --production
- name: Client Build for Web
working-directory: client
env:
CI: false
run: |
npm run build:web:ci
- name: Package Web Build
run: |
cd client/build
tar -czvf ../web_build-${{matrix.network.name}}.tar.gz .
- name: Upload Haven Web Build
uses: a-sync/s3-uploader@master
with:
args: --acl public-read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-west-1
S3_BUCKET: ${{ secrets.AWS_BUCKET }}
FILE: ./client/web_build-${{matrix.network.name}}.tar.gz
S3_KEY: binaries/${{github.ref_name}}/web_build-${{matrix.network.name}}.tar.gz
- name: Upload on web hosting
uses: a-sync/s3-uploader@master
with:
args: --recursive --acl public-read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-west-1
S3_BUCKET: haven-vault-${{matrix.network.name}}
FILE: ./client/build
- name: notification
env:
BINARY_NAME: /web_build-${{matrix.network.name}}.tar.gz
BINARY_URL: https://docs.havenprotocol.org/binaries/
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
shell: bash
run: |
export checksum=($(sha256sum ./client/web_build-${{matrix.network.name}}.tar.gz))
export payload='{"username": "Github", "content": "Web build for ${{matrix.network.name}} : '${BINARY_URL}${GITHUB_REF_NAME}${BINARY_NAME}' (sha256 checksum : '${checksum}')"}'
echo $payload
curl -X POST -H "Content-Type: application/json" -d "$payload" $DISCORD_WEBHOOK
- name: Upload binaries to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./client/web_build-${{matrix.network.name}}.tar.gz
asset_name: web_build-${{matrix.network.name}}.tar.gz
tag: ${{ github.ref }}
overwrite: true
body: ""
prerelease: true
invalidate-cache:
runs-on: ubuntu-latest
needs:
- web-build
steps:
- name: Cloudfront Purge Cache
uses: unfor19/install-aws-cli-action@master
with:
version: 2
- run: |
aws s3 ls s3://haven-docs
aws cloudfront create-invalidation --debug --distribution-id ${{ secrets.CLOUDFRONT_MAINNET }} --paths "/*"
aws cloudfront create-invalidation --debug --distribution-id ${{ secrets.CLOUDFRONT_STAGENET }} --paths "/*"
aws cloudfront create-invalidation --debug --distribution-id ${{ secrets.CLOUDFRONT_TESTNET }} --paths "/*"
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-1
- name: Cloudflare Purge Cache
uses: jakejarvis/cloudflare-purge-action@v0.3.0
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}