58 lines
1.7 KiB
YAML
58 lines
1.7 KiB
YAML
name: Knowledge Base Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
inputs:
|
|
environment:
|
|
type: choice
|
|
description: 选择部署环境
|
|
required: true
|
|
default: test
|
|
options:
|
|
- test
|
|
- prod
|
|
|
|
env:
|
|
DEPLOY_HOST: micecola.top
|
|
DEPLOY_USER: root
|
|
TEST_DIR: /www/wwwroot/kb-web-test/zhangqing
|
|
PROD_DIR: /www/wwwroot/kb-web/zhangqing
|
|
|
|
jobs:
|
|
# ==================== 测试环境部署 ====================
|
|
deploy-test:
|
|
runs-on: host
|
|
if: github.event_name == 'push' || github.inputs.environment == 'test'
|
|
steps:
|
|
- name: Deploy to test environment
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ env.DEPLOY_HOST }}
|
|
username: ${{ env.DEPLOY_USER }}
|
|
key: ${{ secrets.DEPLOY_KEY }}
|
|
script: |
|
|
rm -rf ${{ env.TEST_DIR }}
|
|
git clone --depth 1 -b main ssh://gitea-external/starmen1265/knowledge-base.git ${{ env.TEST_DIR }}
|
|
rm -rf ${{ env.TEST_DIR }}/.git
|
|
chown -R www:www ${{ env.TEST_DIR }}
|
|
|
|
# ==================== 正式环境部署(手动) ====================
|
|
deploy-prod:
|
|
runs-on: host
|
|
if: github.inputs.environment == 'prod'
|
|
steps:
|
|
- name: Deploy to production
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ env.DEPLOY_HOST }}
|
|
username: ${{ env.DEPLOY_USER }}
|
|
key: ${{ secrets.DEPLOY_KEY }}
|
|
script: |
|
|
rm -rf ${{ env.PROD_DIR }}
|
|
git clone --depth 1 -b main ssh://gitea-external/starmen1265/knowledge-base.git ${{ env.PROD_DIR }}
|
|
rm -rf ${{ env.PROD_DIR }}/.git
|
|
chown -R www:www ${{ env.PROD_DIR }}
|