#!/usr/bin/env bash # Creates (if missing) and pushes template/ to $GITEA_TEMPLATE_REPO in Gitea. set -euo pipefail cd "$(dirname "$0")/.." ROOT="$PWD" [ -f .env ] && set -a && . ./.env && set +a . scripts/gitea-lib.sh REPO="${GITEA_TEMPLATE_REPO:-peppa/template}" OWNER="${REPO%%/*}"; NAME="${REPO##*/}" gitea_create_repo "$OWNER" "$NAME" "Peppa project template" ',"template":true' TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT git clone -q "$GITEA_URL/$REPO.git" "$TMP" -c credential.helper=peppa 2>/dev/null || git -C "$TMP" init -q -b main cd "$TMP" gitea_git_setup git remote get-url origin >/dev/null 2>&1 || git remote add origin "$GITEA_URL/$REPO.git" find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + cp -R "$ROOT/template/." . git add -A if git diff --cached --quiet; then echo "template unchanged"; exit 0; fi git commit -qm "Update Peppa template ($(git -C "$ROOT" rev-parse --short HEAD))" git push -q origin HEAD:main echo "pushed template to $GITEA_URL/$REPO"