maintain | 固化推送流程:wiki-push.ps1、WIKI-SCHEMA 第10节、.gitignore 排除 Obsidian 运行时文件

This commit is contained in:
AAsige
2026-08-07 04:52:21 +08:00
parent c6ec760e71
commit 084650a35c
5 changed files with 112 additions and 245 deletions
+74
View File
@@ -0,0 +1,74 @@
#requires -Version 7
<#
.SYNOPSIS
一键提交并推送到自建 Gitea 远程(jzy/my_wiki)。
.DESCRIPTION
固化推送流程:可选先运行 wiki-audit.ps1 审计门禁,然后
git add -A -> commit -> push gitea main,最后显示同步状态。
不修改任何知识正文,只负责版本控制操作。
.PARAMETER Message
提交信息。缺省时自动生成 "maintain | YYYY-MM-DD Wiki 增量更新"。
.PARAMETER Audit
推送前先运行 tools/wiki-audit.ps1;审计存在 ERROR 时中止推送。
.PARAMETER FailOnWarning
与 -Audit 配合使用:将审计 WARNING 也视为失败(严格门禁)。
.EXAMPLE
pwsh -File .\tools\wiki-push.ps1 -Message "ingest | 8 月焦煤日报登记"
pwsh -File .\tools\wiki-push.ps1 -Audit -Message "维护后推送"
#>
param(
[string]$Message = '',
[switch]$Audit,
[switch]$FailOnWarning
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
Set-Location $root
# 1) 可选审计门禁:ERROR 阻断,WARNING 默认放行(-FailOnWarning 时也阻断)
if ($Audit) {
$auditArgs = @('-NoProfile', '-File', (Join-Path $root 'tools\wiki-audit.ps1'))
if ($FailOnWarning) { $auditArgs += '-FailOnWarning' }
& pwsh @auditArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "审计未通过(exit $LASTEXITCODE),已中止推送。"
exit 1
}
Write-Host '[1/4] 审计通过。' -ForegroundColor Green
} else {
Write-Host '[1/4] 跳过审计(使用 -Audit 可在推送前执行)。' -ForegroundColor DarkGray
}
# 2) 检查变更
$changes = git status --porcelain
if (-not $changes) {
Write-Host '[2/4] 没有待提交的变更,无需推送。' -ForegroundColor Yellow
exit 0
}
Write-Host "[2/4] 待提交变更 $((($changes | Measure-Object).Count)) 项。" -ForegroundColor Cyan
$changes | ForEach-Object { Write-Host " $_" -ForegroundColor DarkGray }
# 3) 提交
if (-not $Message) {
$Message = "maintain | $(Get-Date -Format 'yyyy-MM-dd') Wiki 增量更新"
}
git add -A
git commit -m $Message
if ($LASTEXITCODE -ne 0) { Write-Error 'git commit 失败。'; exit 1 }
Write-Host '[3/4] 提交完成。' -ForegroundColor Green
# 4) 推送(唯一远程 gitea,显式指定分支)
git push gitea main
if ($LASTEXITCODE -ne 0) { Write-Error 'git push 失败,请检查网络与凭据(.git/config 中的 token)。'; exit 1 }
Write-Host '[4/4] 推送完成。' -ForegroundColor Green
# 5) 结果
git status -sb | Select-Object -First 1
Write-Host "推送内容:$Message"
exit 0