-
Notifications
You must be signed in to change notification settings - Fork 10
105 lines (90 loc) · 2.86 KB
/
ci.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
name: Thrershold Website CI
on:
pull_request:
branches:
- main
- threshold-site-2.0
push:
branches:
- main
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: "Set up security.txt and .well-known/security.txt"
run: |
mkdir static/.well-known
cp static/security.txt static/.well-known/security.txt
- name: Build preview
if: github.event_name == 'pull_request'
run: yarn build:prefixed
env:
PUBLIC_URL: /${{ github.head_ref }}
- name: Build
if: github.event_name == 'push'
run: yarn build
env:
PUBLIC_URL: /
POSTHOG_SUPPORT: true
POSTHOG_API_KEY: ${{ secrets.MAINNET_POSTHOG_API_KEY }}
POSTHOG_HOSTNAME_HTTP: ${{ secrets.MAINNET_POSTHOG_HOSTNAME_HTTP }}
- uses: actions/upload-artifact@v3
with:
name: build
path: public
deploy-preview:
name: Deploy preview
needs: build
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Deploy PR to GCP
uses: thesis/[email protected]
with:
service-key: ${{ secrets.PROD_PREVIEW_UPLOADER_SERVICE_KEY_JSON_BASE64 }}
project: ${{ secrets.PROD_PREVIEW_GOOGLE_PROJECT_ID }}
bucket-name: preview.threshold.network
bucket-path: ${{ github.head_ref }}
build-folder: build
- name: Post preview URL to PR
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Preview uploaded to https://preview.threshold.network/${{ github.head_ref }}/index.html.'
})
deploy:
name: Deploy
needs: build
if: github.event_name == 'push'
# production environment is protected, it requires an approval before execution.
environment:
name: prod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Deploy build to GCP
uses: thesis/[email protected]
with:
service-key: ${{ secrets.PROD_UPLOADER_SERVICE_KEY_JSON_BASE64 }}
project: ${{ secrets.PROD_GOOGLE_PROJECT_ID }}
bucket-name: threshold.network
build-folder: build
set-website: true
home-page-path: index.html
error-page-path: index.html