From 3548ba565f3252f6898f6169f07f634c07f5531a Mon Sep 17 00:00:00 2001 From: starmen1265 Date: Mon, 16 Feb 2026 22:41:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=8B=E5=8A=A8=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=B5=8B=E8=AF=95/=E6=AD=A3=E5=BC=8F=E7=8E=AF?= =?UTF-8?q?=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index c0dbc11..cf15cf8 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -4,6 +4,16 @@ on: push: branches: - main + workflow_dispatch: + inputs: + environment: + type: choice + description: 选择部署环境 + required: true + default: test + options: + - test + - prod env: DEPLOY_HOST: micecola.top @@ -12,9 +22,10 @@ env: PROD_DIR: /www/wwwroot/kb-web/zhangqing jobs: - # ==================== 测试环境部署(自动) ==================== + # ==================== 测试环境部署 ==================== deploy-test: runs-on: ubuntu-latest + if: github.event_name == 'push' || github.inputs.environment == 'test' steps: - name: Deploy to test environment uses: appleboy/ssh-action@v1 @@ -38,3 +49,31 @@ jobs: - name: Notify run: echo "✅ 测试环境: http://${{ env.DEPLOY_HOST }}:8081" + + # ==================== 正式环境部署(手动) ==================== + deploy-prod: + runs-on: ubuntu-latest + 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 }} + + # 删除 .git 目录 + rm -rf ${{ env.PROD_DIR }}/.git + + # 设置权限 + chown -R www:www ${{ env.PROD_DIR }} + + echo "✅ 正式环境知识库部署完成" + echo "文件数: $(find ${{ env.PROD_DIR }} -type f | wc -l)" + + - name: Notify + run: echo "✅ 正式环境: http://${{ env.DEPLOY_HOST }}"