Skip to content

Commit 8a7aa60

Browse files
committed
feat: add action
1 parent 9c43348 commit 8a7aa60

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build and Deploy via SFTP
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
# 只在指定仓库中运行
12+
if: github.repository == 'langhuihui/m7s-website'
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '18'
22+
cache: 'npm'
23+
24+
- name: Install pnpm
25+
uses: pnpm/action-setup@v4
26+
with:
27+
version: latest
28+
29+
- name: Install dependencies
30+
run: pnpm install
31+
32+
- name: Build project
33+
run: pnpm run build
34+
35+
- name: Deploy to server via SFTP
36+
uses: SamKirkland/[email protected]
37+
with:
38+
server: ${{ secrets.SFTP_HOST }}
39+
username: ${{ secrets.SFTP_USERNAME }}
40+
password: ${{ secrets.SFTP_PASSWORD }}
41+
port: ${{ secrets.SFTP_PORT }}
42+
protocol: sftp
43+
local-dir: ./.vitepress/dist/
44+
server-dir: ${{ secrets.SFTP_SERVER_DIR }}
45+
exclude: |
46+
**/.git*
47+
**/.git*/**
48+
**/node_modules/**
49+
.env

0 commit comments

Comments
 (0)