accounts/.github/workflows/deploy-xcontrol-panel.yml
2025-08-09 12:38:16 +08:00

59 lines
1.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Deploy Xcontrol-panel to Cloudflare Pages
on:
pull_request:
paths:
- 'ui/panel/**'
- '.github/workflows/deploy-xcontrol-panel.yml'
workflow_dispatch:
paths:
- 'ui/panel/**'
- '.github/workflows/deploy-xcontrol-panel.yml'
branches: [main]
workflow_call:
jobs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui/panel/
steps:
- name: 📦 Checkout source code
uses: actions/checkout@v4
- name: 🧰 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: 📥 Install dependencies
run: yarn install --frozen-lockfile
- name: 🛠️ Build static site
run: yarn build # next build (output: 'export' 会自动产出 ./out)
- name: 🚀 Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: xcontrol-panel # 和 Pages 控制台里看到的项目名保持一致
directory: ui/panel/out # 指定到子目录 out
wranglerVersion: '4' # 升级到 Wrangler v4避免 v2 大量警告
# - name: 📤 Deploy to VPS via rsync
# env:
# RSYNC_SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# VPS_HOST: ${{ secrets.VPS_HOST }}
# run: |
# mkdir -p ~/.ssh
# echo "$RSYNC_SSH_KEY" > ~/.ssh/id_rsa
# chmod 600 ~/.ssh/id_rsa
# ssh-keyscan -H "$VPS_HOST" >> ~/.ssh/known_hosts
# rsync -av out/ root@"$VPS_HOST":/mnt/data/website/ --delete
- name: ✅ Confirm deployment complete
run: echo "✅ Homepage deployed to Cloudflare & VPS Site."