Repository navigation
81 lines (73 loc) · 2.83 KB
/
Copy pathdeploy-website.yml
File metadata and controls
81 lines (73 loc) · 2.83 KB
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
name: Deploy Website
on:
push:
branches: [main]
paths: ['website/**']
# 手动触发入口:用于部署链路验证与紧急重部署(不依赖路径变更)
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: website/package-lock.json
- name: Install dependencies and build
env:
# 下载源基址:配置了 CDN 后填入该 Secret(如 https://dl.entropydecrease.com);
# 未配置时为空字符串,前端自动回退至自建服务器
NEXT_PUBLIC_DOWNLOAD_BASE: ${{ secrets.DOWNLOAD_BASE_URL }}
run: |
cd website
npm ci
npm run build
- name: Ensure target directory exists
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: mkdir -p /opt/Entropydecrease/website
- name: Upload static files to server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: website/out/*
target: /opt/Entropydecrease/website
strip_components: 2
rm: true
- name: Restart Nginx and verify deployment
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
# scp 的 rm:true 会重建挂载目录导致 bind mount 失效,必须重启容器
docker restart entropy-decrease-nginx
sleep 5
curl -sf https://entropydecrease.com/ | grep -q "熵减" || exit 1
- name: Notify IndexNow
run: |
curl -sf -X POST "https://api.indexnow.org/indexnow" \
-H "Content-Type: application/json; charset=utf-8" \
-d '{
"host": "entropydecrease.com",
"key": "2483a0d298b94b62a30be65fce88940e",
"keyLocation": "https://entropydecrease.com/2483a0d298b94b62a30be65fce88940e.txt",
"urlList": [
"https://entropydecrease.com/",
"https://entropydecrease.com/download",
"https://entropydecrease.com/philosophy",
"https://entropydecrease.com/features",
"https://entropydecrease.com/features/dive",
"https://entropydecrease.com/support",
"https://entropydecrease.com/faq"
]
}' || echo "IndexNow notify failed (non-blocking)"