-
Notifications
You must be signed in to change notification settings - Fork 8
181 lines (150 loc) · 4.79 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
name: deploy
on:
push:
branches:
- main
pull_request:
release:
types: [published]
env:
BRANCH_NAME: ${{ github.ref_name }}
permissions:
pull-requests: write
jobs:
build_frontend:
name: Build Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Setup Rust
run: |
rustup toolchain install stable
rustup target add wasm32-unknown-unknown
- name: Build for Prod
if: github.event_name == 'release'
run: |
pnpm install
pnpm --filter ./packages/frontend run build
- name: Build for Staging
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: |
pnpm install
pnpm --filter ./packages/frontend run build --mode staging
- name: Upload
uses: actions/upload-artifact@v4
with:
name: app
path: packages/frontend/dist
- name: Build Frontend Docs
run: |
pnpm --filter ./packages/frontend run doc
- name: Upload
uses: actions/upload-artifact@v4
with:
name: frontend_docs
path: packages/frontend/docs
build_rust_docs:
name: Build Rust Docs
runs-on: ubuntu-latest
steps:
- name: Repository Checkout
uses: actions/checkout@v4
- name: Setup Rust
run: |
rustup toolchain install stable
- name: Build
run: |
cargo doc --all-features --no-deps
- name: Upload rust docs
uses: actions/upload-artifact@v4
with:
name: rust_docs
path: target/doc
build_dev-docs:
name: Build dev-docs
runs-on: ubuntu-latest
steps:
- name: Repository Checkout
uses: actions/checkout@v4
- name: Setup TinyTeX
uses: r-lib/actions/setup-tinytex@v2
- name: Install TeX Packages
run: |
tlmgr update --self
tlmgr install dvisvgm
tlmgr install standalone
tlmgr install pgf
tlmgr install tikz-cd
tlmgr install amsmath
tlmgr install quiver
- name: Build
run: |
cd dev-docs
./forester build
- name: Upload
uses: actions/upload-artifact@v4
with:
name: dev-docs
path: dev-docs/output
deploy:
name: Deploy to netlify
runs-on: ubuntu-latest
needs: [build_dev-docs, build_frontend, build_rust_docs]
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'ToposInstitute/CatColab'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Install Netlify
run: |
cd .netlify-env
pnpm install
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Consolidate
run: |
mv app site/
mv dev-docs site/dev
mv rust_docs site/dev/rust
mv frontend_docs site/dev/frontend
echo '/dev /dev/index.xml' >> site/_redirects
echo '/* /index.html 200' >> site/_redirects
- name: Deploy to Staging
if: github.event_name == 'push' || github.event_name == 'pull_request'
id: netlify_deploy
run: |
cd .netlify-env
prod_flag=""
if [ "$BRANCH_NAME" = "main" ]; then prod_flag="--prod"; fi
npx netlify deploy --dir ../site --site ${{ secrets.NETLIFY_SITE_ID }} --auth ${{ secrets.NETLIFY_API_TOKEN }} $prod_flag --json > ../deploy_output.json
- name: Deploy to Prod
if: github.event_name == 'release'
run: |
cd .netlify-env
npx netlify deploy --dir ../site --site ${{ secrets.NETLIFY_PROD_SITE_ID }} --auth ${{ secrets.NETLIFY_API_TOKEN }} --prod
- name: Generate URL Preview
id: url_preview
if: env.BRANCH_NAME != 'main' && (github.event_name == 'push' || github.event_name == 'pull_request')
run: |
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json)
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"
- name: Comment URL Preview on PR
uses: mshick/add-pr-comment@v2
if: env.BRANCH_NAME != 'main' && (github.event_name == 'push' || github.event_name == 'pull_request')
with:
message: |
Preview url: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}