ci(deploy): 改为 GitHub Webhook 触发部署

This commit is contained in:
admin committed 2026-10-20 14:23:31 +08:00
1 parent 69bfe3ce0e
commit 469630e7da
11 files changed
+267 -78

No files matched your search

+21 -37
View File
@@ -1,48 +1,32 @@
name: Deploy WeReadBoard
name: Verify WeReadBoard
on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev
workflow_dispatch:
jobs:
deploy:
verify:
runs-on: ubuntu-latest
concurrency:
group: deploy-master
cancel-in-progress: true
steps:
- name: Prepare SSH
run: |
mkdir -p ~/.ssh
printf '%s\n' "${{ secrets.SERVER_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
- name: Deploy
env:
SERVER_HOST: ${{ secrets.SERVER_HOST }}
SERVER_PORT: ${{ secrets.SERVER_PORT }}
SERVER_USER: ${{ secrets.SERVER_USER }}
DEPLOY_PATH: ${{ vars.DEPLOY_PATH }}
SERVICE_NAME: ${{ vars.SERVICE_NAME }}
DEPLOY_BRANCH: master
run: |
if [ -z "$SERVER_PORT" ]; then
SERVER_PORT="22"
fi
if [ -z "$DEPLOY_PATH" ]; then
DEPLOY_PATH="/opt/weread-board/WeReadBoard"
fi
if [ -z "$SERVICE_NAME" ]; then
SERVICE_NAME="weread.service"
fi
ssh -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -p "$SERVER_PORT" "$SERVER_USER@$SERVER_HOST" \
"cd '$DEPLOY_PATH' &&
git fetch origin &&
git checkout '$DEPLOY_BRANCH' &&
git pull --ff-only origin '$DEPLOY_BRANCH' &&
chmod +x ./deploy.sh &&
SKIP_GIT_PULL=1 DEPLOY_BRANCH='$DEPLOY_BRANCH' SERVICE_NAME='$SERVICE_NAME' ./deploy.sh"
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: python -m pip install -r requirements.txt
- name: Run Python tests
run: python -m unittest discover -s tests -v
- name: Run frontend tests
run: node --test tests/goals_frontend.test.cjs tests/weapi_fallback.test.cjs
- name: Check deployment scripts
run: bash tests/deploy_master_only.test.sh && bash -n deploy.sh