blob: 2099d293f66aa2d4bab0c59b7715cbf5bf34124c (
plain)
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
|
name: Deploy to VPS
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 1) Checkout your code
- uses: actions/checkout@v3
# 2) Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
# 3) Install dependencies & build
- name: Install & Build
run: |
npm ci
npm run build # Vite’s default output dir is `dist/`
# 4) Clean remote dir
- name: Clean remote directory
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
script: |
rm -rf ${{ secrets.VPS_DESTINATION }}/*
# 5) Copy build output to VPS via SCP
- name: Deploy build via SCP
uses: appleboy/scp-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
source: "dist/*"
target: ${{ secrets.VPS_DESTINATION }}
# 6) Restart Nginx inside Docker on your VPS
- name: Restart Nginx (Docker)
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
script: |
docker restart nginx
|