-
Notifications
You must be signed in to change notification settings - Fork 9
210 lines (174 loc) · 5.37 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
name: CI
on:
push:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: ESLint
run: pnpm run lint
type-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Type Check
run: pnpm run type-check
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Install Playwright browser
run: pnpm exec playwright install chromium
- name: Run tests
run: pnpm run test:cov
- name: Upload coverage reports to Codecov
if: always() && github.repository == 'mc-wiki/mcw-calc' && github.ref == 'refs/heads/main'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Sync translations
uses: crowdin/github-action@v2
if: github.repository == 'mc-wiki/mcw-calc' && github.ref == 'refs/heads/main'
with:
upload_sources: true
upload_translations: true
import_eq_suggestions: false
download_sources: false
download_translations: true
push_translations: true
commit_message: New Crowdin translations [skip ci]
localization_branch_name: main
create_pull_request: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: 684734
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build --base=/static/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
deploy:
needs: build
if: (!contains(github.event.head_commit.message , '[skip ci]') && github.repository == 'mc-wiki/mcw-calc' && github.ref == 'refs/heads/main') || github.event == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
deployments: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Create GitHub deployment
uses: chrnorm/deployment-action@v2
id: deployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment-url: https://tools.minecraft.wiki/static/
environment: production
- name: Deploy to MW
run: pnpm run deploy
env:
ACCESS_TOKEN_PROD: ${{ secrets.ACCESS_TOKEN_PROD }}
# ACCESS_TOKEN_DEV: ${{ secrets.ACCESS_TOKEN_DEV }}
- name: rsync deployments
uses: burnett01/[email protected]
with:
switches: -avzr --delete
path: dist/
remote_path: /var/www/html/static/
remote_host: ${{ secrets.TOOLS_SSH_IP }}
remote_user: ${{ secrets.TOOLS_SSH_USER }}
remote_key: ${{ secrets.TOOLS_SSH_PRIVATE_KEY }}
- name: Purge Cloudflare cache
run: pnpm run purge
env:
WG_API_TOKEN: ${{ secrets.WG_API_TOKEN }}
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment-url: https://tools.minecraft.wiki/static/tools/
state: success
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment-url: https://tools.minecraft.wiki/static/tools/
state: failure
deployment-id: ${{ steps.deployment.outputs.deployment_id }}