Some checks failed
Update Code / StopService (windows-101.36.104.175) (push) Successful in 1s
Update Code / StopService (windows-101.36.102.136) (push) Successful in 0s
Update Code / CD (windows-101.36.104.175) (push) Failing after 2s
Update Code / CD (windows-101.36.102.136) (push) Failing after 2s
79 lines
2.3 KiB
YAML
79 lines
2.3 KiB
YAML
name: Update Code
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
env:
|
|
DESTINATION: C:\Facebook
|
|
REPOSITORY_URL: http://deploy:123qwe123@123.58.209.87:3000/he/py_facebook.git
|
|
|
|
jobs:
|
|
StopService:
|
|
runs-on: ${{ matrix.machine }}
|
|
defaults:
|
|
run:
|
|
shell: powershell
|
|
strategy:
|
|
matrix:
|
|
machine:
|
|
- windows-101.36.102.136
|
|
- windows-101.36.104.175
|
|
steps:
|
|
- name: Stop previous service
|
|
run: |
|
|
try {
|
|
Stop-Process -Name "python" -Force -ErrorAction SilentlyContinue
|
|
} catch {}
|
|
|
|
CD:
|
|
needs: StopService
|
|
runs-on: ${{ matrix.machine }}
|
|
defaults:
|
|
run:
|
|
shell: powershell
|
|
strategy:
|
|
matrix:
|
|
machine:
|
|
- windows-101.36.102.136
|
|
- windows-101.36.104.175
|
|
steps:
|
|
- name: Debug - Check variables
|
|
run: |
|
|
Write-Host "Repository URL: ${{ env.REPOSITORY_URL }}"
|
|
Write-Host "Destination: ${{ env.DESTINATION }}"
|
|
- name: 更新或clone项目
|
|
shell: powershell
|
|
run: |
|
|
if (-not (Test-Path -Path "${{ env.DESTINATION }}\.git")) {
|
|
# 目录不存在,执行 git clone
|
|
git clone "${{ env.REPOSITORY_URL }}" "${{ env.DESTINATION }}"
|
|
}
|
|
else {
|
|
# 目录存在,更新远程地址并拉取
|
|
Set-Location "${{ env.DESTINATION }}"
|
|
# 检查并更新远程地址
|
|
git remote set-url origin "${{ env.REPOSITORY_URL }}"
|
|
git pull
|
|
}
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: "3.10"
|
|
- name: Install dependencies
|
|
run: |
|
|
Set-Location ${{ env.DESTINATION }}
|
|
"${{ matrix.machine }}" | Set-Content -Path "ip.txt" -Encoding UTF8
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
python -m playwright install
|
|
python -m playwright install-deps
|
|
# python -m playwright install msedge
|
|
- name: PIP LIST
|
|
run: pip list
|
|
- name: Start FastAPI server
|
|
timeout-minutes: 3 # 设定超时时间为 3 分钟
|
|
run: |
|
|
Set-Location ${{ env.DESTINATION }}
|
|
Start-Process -WindowStyle hidden -FilePath python .\main.py
|