-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 3.16 KB
/
nebula-build-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
name: Build and Deploy
on:
push:
branches: [main] # Set this to the branch you want to deploy from
jobs:
build:
defaults:
run:
working-directory: ./nebula
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
name: "Test nebula on ${{matrix.os}}"
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal --no-self-update
- name: Compile tailwind styling
run: |
cd nebula_server
npm install
npx tailwindcss -i styles/tailwind.css -o ../assets/main.css
- uses: Swatinem/rust-cache@v2
with:
workspaces: nebula
- run: |
cargo build --release
- name: Prepare deploy
run: |
mkdir deploy
cp target/release/nebula_server deploy/
cp -r assets deploy/
ls -l
- name: Shut down previous Nebula version
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
if systemctl is-active --quiet nebula_server.service; then
echo "Service is active. Stopping service..."
sudo systemctl stop nebula_server.service
else
echo "Service is not active. No action needed."
fi
- name: Deploy to Server via SCP
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
# password: ${{ secrets.SERVER_PASSWORD }} # Use either password or key
key: ${{ secrets.SERVER_SSH_KEY }}
port: 22
source: "nebula/deploy/*"
target: "/home/debian/apps/nebula"
strip_components: 2
- name: Start
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
SERVICE_FILE=/etc/systemd/system/nebula_server.service
if [ ! -f "$SERVICE_FILE" ]; then
echo "Creating $SERVICE_FILE"
echo "[Unit]" | sudo tee $SERVICE_FILE
echo "Description=Nebula Server Service" | sudo tee -a $SERVICE_FILE
echo "After=network.target" | sudo tee -a $SERVICE_FILE
echo "" | sudo tee -a $SERVICE_FILE
echo "[Service]" | sudo tee -a $SERVICE_FILE
echo " ExecStart=/home/debian/apps/nebula/nebula_server -p 80 -e 0.0.0.0 -a \"/home/debian/apps/nebula/assets\"" | sudo tee -a $SERVICE_FILE
echo "Restart=on-failure" | sudo tee -a $SERVICE_FILE
echo "" | sudo tee -a $SERVICE_FILE
echo "[Install]" | sudo tee -a $SERVICE_FILE
echo "WantedBy=multi-user.target" | sudo tee -a $SERVICE_FILE
sudo systemctl daemon-reload
sudo systemctl enable nebula_server.service
fi
sudo systemctl start nebula_server.service
- name: Clean up
run: rm -rf deploy