From 73064d689693f0af2da91f6081e8d858e9897b0d Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 28 Nov 2025 15:33:13 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=87=B3=E3=80=8C.gitea/workflows=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/main_build_manual.yaml | 51 +++++++++++++++++++++ .gitea/workflows/main_build_schedule.yaml | 54 +++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 .gitea/workflows/main_build_manual.yaml create mode 100644 .gitea/workflows/main_build_schedule.yaml diff --git a/.gitea/workflows/main_build_manual.yaml b/.gitea/workflows/main_build_manual.yaml new file mode 100644 index 0000000..274c849 --- /dev/null +++ b/.gitea/workflows/main_build_manual.yaml @@ -0,0 +1,51 @@ +name: 手动 AiDA WEB-Node.js main 分支构建部署 +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ 20.19.0 ] + + env: + REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/front + + steps: + - name: 1.检出代码 + uses: actions/checkout@v4 + + - name: 2.设置 Node.js 环境 + uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm run build + - run: ls -l + + - name: 3.同步文件到远程服务器 + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SSH_KEY }} + source: "./dist/*" + target: ${{ env.REMOTE_DEPLOY_PATH }} + ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + strip_components: 0 + + - name: 4. 远程重载 Nginx 配置 + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SSH_KEY }} + # 核心:执行 Nginx 重载命令 + script: | + echo "尝试重载 Nginx 服务..." + # 💡 注意:执行此命令需要服务器用户具有 sudo 权限,并且配置了 NOPASSWD。 + # 否则工作流可能会因为权限不足而失败。 + sudo systemctl reload nginx + echo "Nginx 重载命令已发送。" \ No newline at end of file diff --git a/.gitea/workflows/main_build_schedule.yaml b/.gitea/workflows/main_build_schedule.yaml new file mode 100644 index 0000000..24021f9 --- /dev/null +++ b/.gitea/workflows/main_build_schedule.yaml @@ -0,0 +1,54 @@ +name: 定时 AiDA WEB-Node.js main 分支构建部署 +on: + schedule: + # cron为UTC时区,构建时间=部署时间-8小时 {*分 (-8)时 *日 *月 *周} --- + # 示例: 1月1日22点22分触发构建 cron写作 - '22 14 1 1 *' + - cron: '22 14 1 1 *' + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ 20.19.0 ] + + env: + REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/front + + steps: + - name: 1.检出代码 + uses: actions/checkout@v4 + + - name: 2.设置 Node.js 环境 + uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm run build + - run: ls -l + + - name: 3.同步文件到远程服务器 + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SSH_KEY }} + source: "./dist/*" + target: ${{ env.REMOTE_DEPLOY_PATH }} + ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + strip_components: 0 + + - name: 4. 远程重载 Nginx 配置 + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SSH_KEY }} + # 核心:执行 Nginx 重载命令 + script: | + echo "尝试重载 Nginx 服务..." + # 💡 注意:执行此命令需要服务器用户具有 sudo 权限,并且配置了 NOPASSWD。 + # 否则工作流可能会因为权限不足而失败。 + sudo systemctl reload nginx + echo "Nginx 重载命令已发送。" \ No newline at end of file From 4d031341bcf6bc11081f3f6d9adc16f99f5cc3a9 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 28 Nov 2025 16:04:33 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=87=B3=E3=80=8C.gitea/workflows=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/main_build.yaml | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .gitea/workflows/main_build.yaml diff --git a/.gitea/workflows/main_build.yaml b/.gitea/workflows/main_build.yaml new file mode 100644 index 0000000..1c48aad --- /dev/null +++ b/.gitea/workflows/main_build.yaml @@ -0,0 +1,56 @@ +name: git提交控制 AiDA WEB-Node.js main 分支构建部署 +on: + workflow_dispatch: + + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + if: "contains(github.event.head_commit.message, '[run build]')" + + strategy: + matrix: + node-version: [ 20.19.0 ] + + env: + REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/front + + steps: + - name: 1.检出代码 + uses: actions/checkout@v4 + + - name: 2.设置 Node.js 环境 + uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm run build + - run: ls -l + + - name: 3.同步文件到远程服务器 + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SSH_KEY }} + source: "./dist/*" + target: ${{ env.REMOTE_DEPLOY_PATH }} + ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + strip_components: 0 + + - name: 4. 远程重载 Nginx 配置 + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SSH_KEY }} + # 核心:执行 Nginx 重载命令 + script: | + echo "尝试重载 Nginx 服务..." + # 💡 注意:执行此命令需要服务器用户具有 sudo 权限,并且配置了 NOPASSWD。 + # 否则工作流可能会因为权限不足而失败。 + sudo systemctl reload nginx + echo "Nginx 重载命令已发送。" \ No newline at end of file From 71bfd347b7fabf2143d853d53ccc46ec5f81d157 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 28 Nov 2025 16:05:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/main?= =?UTF-8?q?=5Fbuild=5Fcommit.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/{main_build.yaml => main_build_commit.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .gitea/workflows/{main_build.yaml => main_build_commit.yaml} (100%) diff --git a/.gitea/workflows/main_build.yaml b/.gitea/workflows/main_build_commit.yaml similarity index 100% rename from .gitea/workflows/main_build.yaml rename to .gitea/workflows/main_build_commit.yaml From 75ebc649bed901d7db66aa65ad69902ef80895a1 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 28 Nov 2025 16:06:06 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/main?= =?UTF-8?q?=5Fbuild=5Fcommit.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit