Skip to content

Commit d18f6ba

Browse files
committed
feat: add unified VPS deploy workflow
1 parent d2bbe63 commit d18f6ba

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
workflow_dispatch:
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '22'
20+
cache: 'yarn'
21+
22+
- name: Install dependencies
23+
run: yarn install --frozen-lockfile
24+
25+
- name: Build docs site
26+
run: yarn docs:build
27+
28+
- name: Package build
29+
run: tar -czf deploy.tar.gz -C build .
30+
31+
- name: Upload to VPS
32+
uses: appleboy/scp-action@v0.1.7
33+
with:
34+
host: ${{ vars.VPS_HOST }}
35+
username: ${{ vars.VPS_USER }}
36+
port: ${{ vars.VPS_PORT || 22 }}
37+
key: ${{ secrets.VPS_SSH_KEY }}
38+
source: deploy.tar.gz
39+
target: /tmp
40+
41+
- name: Deploy on VPS
42+
uses: appleboy/ssh-action@v1.2.0
43+
env:
44+
DEPLOY_PATH: ${{ vars.VPS_DEPLOY_PATH }}
45+
with:
46+
host: ${{ vars.VPS_HOST }}
47+
username: ${{ vars.VPS_USER }}
48+
port: ${{ vars.VPS_PORT || 22 }}
49+
key: ${{ secrets.VPS_SSH_KEY }}
50+
envs: DEPLOY_PATH
51+
script: |
52+
set -e
53+
mkdir -p "$DEPLOY_PATH"
54+
TMP_DIR=$(mktemp -d)
55+
tar -xzf /tmp/deploy.tar.gz -C "$TMP_DIR"
56+
rsync -a --delete "$TMP_DIR"/ "$DEPLOY_PATH"/
57+
rm -rf "$TMP_DIR" /tmp/deploy.tar.gz

0 commit comments

Comments
 (0)