sync full source from private myoffice

This commit is contained in:
myoffice-sync
2026-08-05 10:55:09 +00:00
parent 874796c860
commit 405abdfe69
714 changed files with 70352 additions and 234 deletions
+55 -60
View File
@@ -1,10 +1,9 @@
# Sync allowlisted paths from the private repo to the public Gitea repo (no full source).
# Sync full source from the private repo to the public Gitea repo (manual build + Proxmox scripts).
# Usage:
# $env:GITEA_TOKEN = '<token>' # optional if using SSH remote
# $env:GITEA_TOKEN = '<token>'
# .\proxmox\sync-public.ps1 -GiteaUrl https://gitea.example.com -Owner org -Repo myoffice-public -Push
#
# Allowlist: proxmox/, Docker/, README.md, LICENSE (if present).
# Never syncs MyOffice.* source, _Published, secrets, node_modules, etc.
# Copies tracked git files (plus generates public README.md). Skips private CI, secrets, build junk.
[CmdletBinding()]
param(
@@ -16,7 +15,7 @@ param(
[string]$Repo = 'myoffice-public',
[string]$Branch = 'main',
[string]$Branch = 'master',
[string]$Token = $env:GITEA_TOKEN,
@@ -37,55 +36,16 @@ if (-not $WorkDir) {
$WorkDir = Join-Path $env:TEMP 'myoffice-public-sync'
}
$allowDirs = @('proxmox', 'Docker')
$allowFiles = @('README.md', 'LICENSE', 'LICENSE.md')
$excludeNames = @('.git', '_Published', 'myoffice-publish.tar.gz', 'node_modules', 'data', '.env', 'env.local')
function Test-Excluded([string]$Name) {
return $excludeNames -contains $Name
}
function Copy-Allowlisted {
param([string]$DestRoot)
foreach ($dir in $allowDirs) {
$src = Join-Path $repoRoot $dir
if (-not (Test-Path $src)) {
Write-Host "Skip missing dir: $dir"
continue
}
$dest = Join-Path $DestRoot $dir
if (Test-Path $dest) {
Remove-Item -Recurse -Force $dest
}
New-Item -ItemType Directory -Path $dest -Force | Out-Null
Get-ChildItem -Path $src -Force | Where-Object { -not (Test-Excluded $_.Name) } | ForEach-Object {
if ($dir -eq 'Docker' -and $_.Name -eq 'data') { return }
Copy-Item $_.FullName -Destination (Join-Path $dest $_.Name) -Recurse -Force
}
Write-Host "Synced $dir/"
}
foreach ($file in $allowFiles) {
$src = Join-Path $repoRoot $file
if (Test-Path $src) {
Copy-Item $src -Destination (Join-Path $DestRoot $file) -Force
Write-Host "Synced $file"
}
}
$publicNote = Join-Path $DestRoot 'PUBLIC.md'
@(
'# MyOffice public tree',
'',
'This repository is a **filtered** mirror for Proxmox CT install scripts and Docker demo files.',
'Application **source** stays in the private developer repository.',
'Runnable app binaries are published as **Gitea Releases** (`myoffice-publish.tar.gz`).',
'',
'See [proxmox/README.md](proxmox/README.md).',
''
) | Set-Content -Path $publicNote -Encoding utf8
function Test-SkipPath([string]$RelPath) {
$n = $RelPath -replace '\\', '/'
if ($n -eq '.gitea' -or $n.StartsWith('.gitea/')) { return $true }
if ($n -eq '_Published' -or $n.StartsWith('_Published/')) { return $true }
if ($n -eq 'myoffice-publish.tar.gz') { return $true }
if ($n -eq 'Docker/data' -or $n.StartsWith('Docker/data/')) { return $true }
if ($n -eq '.env' -or $n.StartsWith('.env.') -or $n -eq 'env.local') { return $true }
if ($n -eq 'proxmox/README.public.md') { return $true }
if ($n.EndsWith('.user') -or $n.EndsWith('.suo')) { return $true }
return $false
}
if ($Token) {
@@ -99,7 +59,7 @@ else {
}
Write-Host "-----------------------------------------------"
Write-Host "Sync allowlist -> $Owner/$Repo ($Branch)"
Write-Host "Sync full source -> $Owner/$Repo ($Branch)"
Write-Host "WorkDir: $WorkDir"
Write-Host "-----------------------------------------------"
@@ -129,7 +89,42 @@ Get-ChildItem -Path $WorkDir -Force | Where-Object { $_.Name -ne '.git' } | ForE
Remove-Item $_.FullName -Recurse -Force
}
Copy-Allowlisted -DestRoot $WorkDir
$tracked = git -C $repoRoot ls-files
$copied = 0
$skipped = 0
foreach ($f in $tracked) {
if (Test-SkipPath $f) {
$skipped++
continue
}
$src = Join-Path $repoRoot $f
if (-not (Test-Path -LiteralPath $src)) {
continue
}
$dest = Join-Path $WorkDir $f
$destDir = Split-Path -Parent $dest
if (-not (Test-Path $destDir)) {
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
}
Copy-Item -LiteralPath $src -Destination $dest -Force
$copied++
}
Write-Host "Copied $copied tracked files (skipped $skipped)."
$repoRawBase = "$GiteaUrl/$Owner/$Repo/raw/branch/$Branch"
$template = Join-Path $scriptDir 'README.public.md'
if (-not (Test-Path $template)) {
throw "Missing $template"
}
$readme = Get-Content -LiteralPath $template -Raw -Encoding utf8
$readme = $readme.
Replace('__GITEA_URL__', $GiteaUrl).
Replace('__GITEA_OWNER__', $Owner).
Replace('__GITEA_REPO__', $Repo).
Replace('__GITEA_BRANCH__', $Branch).
Replace('__REPO_RAW_BASE__', $repoRawBase)
Set-Content -LiteralPath (Join-Path $WorkDir 'README.md') -Value $readme -Encoding utf8 -NoNewline
Write-Host "Wrote public README.md"
git -C $WorkDir add -A
$status = git -C $WorkDir status --porcelain
@@ -138,8 +133,8 @@ if (-not $status) {
}
else {
git -C $WorkDir -c user.email='myoffice-sync@local' -c user.name='myoffice-sync' `
commit -m "sync public allowlist from private myoffice"
Write-Host "Committed allowlist snapshot."
commit -m "sync full source from private myoffice"
Write-Host "Committed public snapshot."
}
if ($Push) {
@@ -156,6 +151,6 @@ else {
}
Write-Host ""
Write-Host "Raw base for CT install:"
Write-Host " $GiteaUrl/$Owner/$Repo/raw/branch/$Branch"
Write-Host "Proxmox one-liner:"
Write-Host (' bash -c "$(curl -fsSL {0}/proxmox/myoffice.sh)"' -f $repoRawBase)
Write-Host ""