Skip to content

Commit 075be73

Browse files
committed
chore: add workflow
1 parent 9d98972 commit 075be73

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

.github/workflows/deploy.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Deploy to Server
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Set up SSH
17+
uses: webfactory/[email protected]
18+
with:
19+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
20+
21+
- name: Run deployment script
22+
env:
23+
SERVER_IP: ${{ secrets.SERVER_IP }}
24+
run: |
25+
ssh -o StrictHostKeyChecking=no deploy@$SERVER_IP << 'EOF'
26+
export PATH="$PATH:/home/deploy/.nvm/versions/node/v20.18.1/bin"
27+
cd /home/deploy/blog
28+
git pull origin main
29+
pnpm install
30+
pnpm run build
31+
EOF

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"start": "pnpm dev",
1010
"build:dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider vuepress build src --dest dist",
1111
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider vuepress build src --dest dist",
12-
"postbuild": "mv ./dist/* /var/www/html/"
12+
"postbuild": "bash -c '[ -z \"$VERCEL\" ] && mv -f ./dist/* /var/www/html/blog/'"
1313
},
1414
"engines": {
1515
"node": ">=18.0.0"

0 commit comments

Comments
 (0)