From 14b7d18ecce654d96f598fffe3966612faf39462 Mon Sep 17 00:00:00 2001 From: pqhuy1987 Date: Wed, 29 Apr 2026 16:21:12 +0700 Subject: [PATCH] =?UTF-8?q?[CLAUDE]=20CICD:=20b=E1=BB=8F=20uses:=20actions?= =?UTF-8?q?/*=20=E2=80=94=20manual=20git=20checkout=20t=E1=BB=AB=20Gitea?= =?UTF-8?q?=20(fix=20#108/#109=20fail)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vấn đề persistent (run #108 và #109 đều fail trong 21-22s): Get "https://github.com/actions/checkout/info/refs?service=git-upload-pack": dial tcp 20.205.243.166:443: connectex: connection failed/timeout act_runner v0.2.13 mỗi run đều `git fetch` actions/checkout từ github.com để check update — VPS network → github.com TCP timeout 21s liên tục → toàn job fail TRƯỚC khi tới test gate. Fix: thay actions ngoài bằng native shell, eliminate github.com dependency. - Replace `uses: actions/checkout@v4` → manual `git init` + `git fetch` từ Gitea internal network (luôn ổn định, không qua public internet) - Auth: github.token (act_runner cũng dùng tên này) — tự sẵn per job - Fetch by ref (branch) thay vì SHA, depth=30 đủ buffer nếu main commit thêm trong lúc job pickup - Checkout đúng commit SHA của event push - Log 1-line để confirm checkout đúng - Replace `uses: actions/upload-artifact@v4` (cũng phụ thuộc github.com) → step "List test results" local. TRX file vẫn save trong workspace test-results/, đọc qua runner workspace nếu cần debug. Test gate giữ nguyên (Domain + Infra). dotnet test local 71 pass / 2s. Long-term option (nếu Gitea Actions thêm hỗ trợ): config `github_mirror` trong gitea-runner config.yaml để mirror github.com → Gitea internal, hoặc pre-cache actions/* repos vào runner cache dir. Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitea/workflows/deploy.yml | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 9bc2882..49d2acf 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -20,7 +20,24 @@ jobs: build-deploy: runs-on: windows-latest steps: - - uses: actions/checkout@v4 + # Manual checkout thay vì `uses: actions/checkout@v4` — tránh phụ thuộc + # github.com (act_runner mỗi run đều `git fetch` để check update action, + # khi VPS → github.com TCP timeout 21s thì toàn job fail trước khi tới + # test gate). Gitea internal network luôn ổn định, nên clone trực tiếp. + # Token `${{ github.token }}` (Gitea cũng dùng tên này) tự sẵn cho job. + - name: Checkout (manual git, bypass github.com) + shell: powershell + run: | + git config --global --add safe.directory '*' + git init -q + git remote add origin "https://gitea-actions:${{ github.token }}@git.baocaogiaoduc.vn/${{ github.repository }}.git" + # Fetch ref (branch) thay vì SHA — không cần Gitea allow SHA fetch. + # Depth 30 đủ buffer nếu main đã commit thêm sau khi job pickup. + $ref = "${{ github.ref }}" + if ($ref -like "refs/heads/*") { $ref = $ref.Substring(11) } + git fetch --depth=30 origin $ref + git checkout --quiet "${{ github.sha }}" + git log -1 --oneline - name: Show tool versions shell: powershell @@ -51,14 +68,18 @@ jobs: --results-directory test-results if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - - name: Upload test results + # Upload test results — bỏ vì `actions/upload-artifact@v4` cũng phụ thuộc + # github.com fetch (cùng vấn đề như actions/checkout). TRX file vẫn save + # local trong workspace `test-results/` cho debug khi cần. + - name: List test results (local debug) if: always() - continue-on-error: true # nếu Gitea runner chưa có upload-artifact action, skip không block deploy - uses: actions/upload-artifact@v4 - with: - name: test-results - path: test-results/*.trx - retention-days: 14 + shell: powershell + run: | + if (Test-Path test-results) { + Get-ChildItem test-results -Recurse | Format-Table FullName, Length + } else { + Write-Host "No test-results directory." + } # ============== BUILD ============== - name: Build backend