mirror of
https://github.com/KingHWJ/WeReadBoard.git
synced 2026-11-03 18:24:58 +08:00
ci(deploy): 添加 dev 自动部署脚本
This commit is contained in:
1 parent
e5d1b7fa42
commit
bbc4bdd140
8 files changed
+284
-2
No files matched your search
@@ -0,0 +1,48 @@
|
||||
name: Deploy WeReadBoard
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: deploy-dev
|
||||
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: ${{ github.ref_name }}
|
||||
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"
|
||||
Reference in new issue
Block a user