#!/usr/bin/env bash # # Push this project to the central Gitea repository. # # Run this FROM REPLIT (the development environment). It pushes the `main` # branch to the `gitea` remote so the Mac Mini can pull and redeploy. # # Flow: (this script) Replit -> push to Gitea -> Mac Mini pulls -> Docker redeploys # # One-time setup — add the gitea remote with your Gitea repo URL: # git remote add gitea https://:@//.git # # or via SSH: # git remote add gitea git@:/.git # # After that, just run: # ./scripts/push-to-gitea.sh # # Optional overrides (environment variables): # GIT_REMOTE Remote name (default: gitea) # GIT_BRANCH Branch to push (default: main) # GITEA_REMOTE_URL If set and the remote does not exist, it is added first. set -euo pipefail GIT_REMOTE="${GIT_REMOTE:-gitea}" GIT_BRANCH="${GIT_BRANCH:-main}" # Add the remote automatically if a URL was provided and it is missing. if ! git remote get-url "${GIT_REMOTE}" >/dev/null 2>&1; then if [ -n "${GITEA_REMOTE_URL:-}" ]; then echo "==> Adding '${GIT_REMOTE}' remote -> ${GITEA_REMOTE_URL}" git remote add "${GIT_REMOTE}" "${GITEA_REMOTE_URL}" else echo "ERROR: Git remote '${GIT_REMOTE}' is not configured." >&2 echo " Add it once with:" >&2 echo " git remote add ${GIT_REMOTE} " >&2 echo " Or re-run with the URL inline:" >&2 echo " GITEA_REMOTE_URL= ./scripts/push-to-gitea.sh" >&2 exit 1 fi fi # NOTE: never echo the remote URL — it may contain an embedded token. echo "==> Pushing '${GIT_BRANCH}' to '${GIT_REMOTE}'..." if git push "${GIT_REMOTE}" "${GIT_BRANCH}"; then echo "SUCCESS: Pushed ${GIT_BRANCH} to ${GIT_REMOTE}." echo "Next: on the Mac Mini run ./deploy.sh to pull and redeploy." else echo "ERROR: Push to ${GIT_REMOTE}/${GIT_BRANCH} failed." >&2 exit 1 fi