From 1d816c8f4ec0cd19ac26bcfd06617abab65c13d9 Mon Sep 17 00:00:00 2001 From: work Date: Thu, 9 Apr 2026 13:33:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E9=A1=B9=E7=9B=AEcd=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/cd.yaml | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 04da7bd..c318235 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -5,7 +5,7 @@ on: branches: - master env: - DESTINATION: C:\Facebook + DESTINATION: C:\Facebook2 REPOSITORY_URL: http://deploy:123qwe123@123.58.209.87:3000/he/py_facebook.git jobs: @@ -45,23 +45,14 @@ jobs: - name: 更新或clone项目 shell: powershell run: | - $dest = "${{ env.DESTINATION }}" - - # 检查是否是有效的 Git 仓库 - if (Test-Path -Path "$dest\.git") { - # 是有效的 Git 仓库,更新远程地址并拉取 - Set-Location $dest - git remote set-url origin "${{ env.REPOSITORY_URL }}" - git pull + if (-not (Test-Path -Path $env:DESTINATION\.git)) { + # 目录不存在,执行 git clone + git clone $env:REPOSITORY_URL $env:DESTINATION } else { - # 不是有效的 Git 仓库,删除目录(如果存在)然后重新克隆 - if (Test-Path -Path $dest) { - Write-Host "Removing existing directory: $dest" - Remove-Item -Path $dest -Recurse -Force - } - # 克隆新仓库 - git clone "${{ env.REPOSITORY_URL }}" $dest + # 目录存在,执行 git pull + Set-Location $env:DESTINATION + git pull } - name: Set up Python uses: actions/setup-python@v3 @@ -69,7 +60,7 @@ jobs: python-version: "3.10" - name: Install dependencies run: | - Set-Location ${{ env.DESTINATION }} + Set-Location $env:DESTINATION "${{ matrix.machine }}" | Set-Content -Path "ip.txt" -Encoding UTF8 python -m pip install --upgrade pip pip install -r requirements.txt @@ -81,5 +72,5 @@ jobs: - name: Start FastAPI server timeout-minutes: 3 # 设定超时时间为 3 分钟 run: | - Set-Location ${{ env.DESTINATION }} + Set-Location $env:DESTINATION Start-Process -WindowStyle hidden -FilePath python .\main.py