Sit #22

Merged
xiaowang merged 2 commits from sit into prod 2026-08-28 15:05:02 +08:00
3 changed files with 18 additions and 2 deletions
+2
View File
@@ -14,6 +14,8 @@ jobs:
github.event.pull_request.base.ref == 'prod' &&
github.event.pull_request.head.ref == 'sit'
runs-on: jayucloud
env:
GITHUB_REF_NAME: prod
steps:
- name: 检出合并提交
uses: actions/checkout@v4
@@ -475,8 +475,16 @@ function Invoke-RemoteShellMany {
function Test-GitState {
Push-Location $resolvedRepoRoot
try {
$commit = (& git rev-parse HEAD).Trim()
$branch = (& git branch --show-current).Trim()
$commitOutput = & git rev-parse HEAD
if ($LASTEXITCODE -ne 0 -or $null -eq $commitOutput) {
throw "无法读取当前 Git 提交号。"
}
$commit = ([string]$commitOutput).Trim()
$branchOutput = & git branch --show-current
$branch = if ($null -ne $branchOutput) { ([string]$branchOutput).Trim() } else { "" }
if (-not $branch) {
$branch = if ($env:GITHUB_REF_NAME) { ([string]$env:GITHUB_REF_NAME).Trim() } else { "DETACHED_HEAD" }
}
$status = @(& git status --porcelain)
if ($status.Count -gt 0) {
Write-Warning "当前工作区有 $($status.Count) 个变更路径。"
+6
View File
@@ -1,5 +1,11 @@
# 项目变更记录
## 2026-08-28 修复 Gitea Detached HEAD 构建失败
- 修复 Gitea Actions 检出合并提交后处于 detached HEAD,`git branch --show-current` 返回空值导致 PowerShell `.Trim()` 空引用异常的问题。
- `Test-GitState` 现在在 CI 中使用 `GITHUB_REF_NAME` 作为分支名,并在本地 detached HEAD 场景使用明确的 `DETACHED_HEAD` 标识。
- Salon 生产准备工作流显式设置 `GITHUB_REF_NAME=prod`,保持合并提交构建行为不变。
## 2026-08-27 Gitea Runner 构建工具链修复
- 修复 `jayucloud` Runner 任务容器缺少 `pwsh` 导致 Salon 发布包构建失败的问题。