-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (67 loc) · 2.35 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
name: CI
on:
push:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Install wasm toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
target: wasm32-unknown-unknown
- name: Install Trunk
uses: jetli/[email protected]
with:
version: 'latest'
- name: Install wasm-opt
run: "curl -L -o binaryen.tar.gz https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-x86_64-linux.tar.gz && tar -xzvf ./binaryen.tar.gz"
- name: Build backend
run: cargo build --profile production --bin backend
- name: Build frontend
run: "cd frontend && trunk build --release"
- name: Optimise wasm
run: "cd frontend/dist && ../../binaryen-version_117/bin/wasm-opt -Oz -o opt.wasm $(ls frontend*.wasm) && mv ./opt.wasm $(ls frontend*.wasm)"
- name: Stop currently-running backend
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
sudo /usr/bin/systemctl stop itsjunetime.service
rm /home/junkie/server_files/frontend* 2>/dev/null || :
- name: SCP files
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
source: "target/production/backend,frontend/dist/*"
target: /home/junkie/server_files/
strip_components: 2
overwrite: true
- name: Restart server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
sudo /usr/bin/systemctl daemon-reload
sudo /usr/bin/systemctl start itsjunetime.service
sudo /usr/sbin/nginx -s reload