11name : CI/CD 持续集成
2+
23on : [push, pull_request]
4+
35concurrency :
46 group : ci-${{ github.ref }}
57 cancel-in-progress : true
1416 PNPM_VERSION : 10.15.0
1517
1618jobs :
19+ # ============================================================
20+ # 代码质量检查
21+ # ============================================================
1722 lint :
1823 name : 代码质量检查
1924 runs-on : ubuntu-latest
3439 run : pnpm run typecheck
3540 continue-on-error : false
3641
42+ # ============================================================
43+ # 构建测试 + 打包
44+ # ============================================================
3745 test :
3846 name : 构建测试
3947 runs-on : ubuntu-latest
6977 path : site.tar.gz
7078 retention-days : 3
7179
80+ # ============================================================
81+ # 部署
82+ # ============================================================
7283 deploy :
7384 name : 部署
7485 runs-on : ubuntu-latest
@@ -81,18 +92,25 @@ jobs:
8192 with :
8293 name : site
8394 path : ./
84- - name : 部署
95+ - name : 配置 SSH
8596 uses : webfactory/ssh-agent@v0.9.0
8697 with :
87- ssh-private-key : ${{ secrets.actions }}
98+ ssh-private-key : ${{ secrets.SSH_PRIVATE_KEY }}
99+
100+ - name : 连接 WireGuard VPN
101+ run : |
102+ sudo apt-get update -qq && sudo apt-get install -y -qq wireguard-tools
103+ echo "${{ secrets.WG_CLIENT_CONFIG }}" | sudo tee /etc/wireguard/github-actions.conf > /dev/null
104+ sudo wg-quick up github-actions
105+ sudo wg show
106+
88107 - name : 远程部署
89108 run : |
90109 set -e
91110 mkdir -p ~/.ssh
92- ssh-keyscan -H miragedge.top >> ~/.ssh/known_hosts 2>/dev/null || true
93- ssh-keyscan -H deploy.miragedge.top >> ~/.ssh/known_hosts 2>/dev/null || true
94- scp -o ConnectTimeout=60 site.tar.gz root@deploy.miragedge.top:/tmp/
95- ssh -o ConnectTimeout=60 root@deploy.miragedge.top << 'ENDSSH'
111+ ssh-keyscan -H 20.20.20.1 >> ~/.ssh/known_hosts 2>/dev/null
112+ scp -o ConnectTimeout=60 site.tar.gz root@20.20.20.1:/tmp/
113+ ssh -o ConnectTimeout=60 root@20.20.20.1 << 'ENDSSH'
96114 set -e
97115 mkdir -p /www/MiragEdge/MiragEdge-DocWeb/build/miragedge.top/
98116 rm -rf /www/MiragEdge/MiragEdge-DocWeb/build/miragedge.top/*
@@ -101,4 +119,6 @@ jobs:
101119 echo "✅ 部署成功"
102120 ENDSSH
103121
104-
122+ - name : 断开 WireGuard VPN
123+ if : always()
124+ run : sudo wg-quick down github-actions 2>/dev/null || true
0 commit comments