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
+51 -51
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
# 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:
# export GITEA_TOKEN='<token>'
# ./proxmox/sync-public.sh --gitea-url https://gitea.example.com --owner org --repo myoffice-public --push
#
# Allowlist: proxmox/, Docker/, README.md, LICENSE (if present).
# Copies tracked git files (plus generates public README.md). Skips private CI, secrets, build junk.
set -euo pipefail
@@ -15,7 +15,7 @@ cd "$repo_root"
gitea_url="${GITEA_URL:-}"
owner="${GITEA_OWNER:-}"
repo="${GITEA_REPO:-myoffice-public}"
branch="${BRANCH:-main}"
branch="${BRANCH:-master}"
token="${GITEA_TOKEN:-}"
work_dir="${WORK_DIR:-}"
do_push=false
@@ -71,16 +71,19 @@ if [[ -z "$work_dir" ]]; then
work_dir="${TMPDIR:-/tmp}/myoffice-public-sync"
fi
allow_dirs=(proxmox Docker)
allow_files=(README.md LICENSE LICENSE.md)
exclude_names=('.git' '_Published' 'myoffice-publish.tar.gz' 'node_modules' 'data' '.env' 'env.local')
is_excluded() {
local name="$1"
for x in "${exclude_names[@]}"; do
[[ "$name" == "$x" ]] && return 0
done
return 1
# Paths never published (private CI, secrets, local junk).
should_skip() {
local f="$1"
case "$f" in
.gitea | .gitea/*) return 0 ;;
_Published | _Published/*) return 0 ;;
myoffice-publish.tar.gz) return 0 ;;
Docker/data | Docker/data/*) return 0 ;;
.env | .env.* | env.local) return 0 ;;
*.user | *.suo) return 0 ;;
proxmox/README.public.md) return 0 ;; # baked into public README.md
*) return 1 ;;
esac
}
if [[ -n "$token" ]]; then
@@ -98,7 +101,7 @@ else
fi
echo "-----------------------------------------------"
echo "Sync allowlist -> $owner/$repo ($branch)"
echo "Sync full source -> $owner/$repo ($branch)"
echo "WorkDir: $work_dir"
echo "-----------------------------------------------"
@@ -119,53 +122,50 @@ fi
find "$work_dir" -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
for dir in "${allow_dirs[@]}"; do
src="$repo_root/$dir"
if [[ ! -d "$src" ]]; then
echo "Skip missing dir: $dir"
copied=0
skipped=0
while IFS= read -r -d '' f; do
if should_skip "$f"; then
skipped=$((skipped + 1))
continue
fi
dest="$work_dir/$dir"
mkdir -p "$dest"
while IFS= read -r -d '' item; do
name="$(basename "$item")"
if is_excluded "$name"; then
continue
fi
if [[ "$dir" == Docker && "$name" == data ]]; then
continue
fi
cp -a "$item" "$dest/"
done < <(find "$src" -mindepth 1 -maxdepth 1 -print0)
echo "Synced $dir/"
done
for file in "${allow_files[@]}"; do
src="$repo_root/$file"
if [[ -f "$src" ]]; then
cp -a "$src" "$work_dir/$file"
echo "Synced $file"
src="$repo_root/$f"
if [[ ! -e "$src" ]]; then
continue
fi
done
dest="$work_dir/$f"
mkdir -p "$(dirname "$dest")"
cp -a "$src" "$dest"
copied=$((copied + 1))
done < <(git -C "$repo_root" ls-files -z)
cat >"$work_dir/PUBLIC.md" <<'EOF'
# MyOffice public tree
echo "Copied $copied tracked files (skipped $skipped)."
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`).
repo_raw_base="${gitea_url}/${owner}/${repo}/raw/branch/${branch}"
readme_template="$script_dir/README.public.md"
if [[ ! -f "$readme_template" ]]; then
echo "Missing $readme_template" >&2
exit 1
fi
sed \
-e "s|__GITEA_URL__|${gitea_url}|g" \
-e "s|__GITEA_OWNER__|${owner}|g" \
-e "s|__GITEA_REPO__|${repo}|g" \
-e "s|__GITEA_BRANCH__|${branch}|g" \
-e "s|__REPO_RAW_BASE__|${repo_raw_base}|g" \
"$readme_template" >"$work_dir/README.md"
echo "Wrote public README.md"
See [proxmox/README.md](proxmox/README.md).
EOF
# Drop private-only docs that confuse public consumers (optional keep docs/)
# Keep docs/ — useful for auth notes.
git -C "$work_dir" add -A
if [[ -z "$(git -C "$work_dir" status --porcelain)" ]]; then
echo "No changes to commit."
else
git -C "$work_dir" -c user.email='myoffice-sync@local' -c user.name='myoffice-sync' \
commit -m "sync public allowlist from private myoffice"
echo "Committed allowlist snapshot."
commit -m "sync full source from private myoffice"
echo "Committed public snapshot."
fi
if [[ "$do_push" == true ]]; then
@@ -178,6 +178,6 @@ else
fi
echo ""
echo "Raw base for CT install:"
echo " $gitea_url/$owner/$repo/raw/branch/$branch"
echo "Proxmox one-liner:"
echo " bash -c \"\$(curl -fsSL ${repo_raw_base}/proxmox/myoffice.sh)\""
echo ""