Files
Ehsan/scripts/push-to-gitea.sh
T
Replit Agent 9e602d53fa Add deployment workflow to push code to Gitea and redeploy on Mac Mini
Configure Replit project for deployment to a self-hosted Gitea repository, including a `deploy.sh` script on a Mac Mini to pull changes, stop, rebuild, and restart Docker containers.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1fa9329f-0cec-4a2f-80e8-e26dbae3142e
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 29017a07-e519-4b14-bdf7-b913b959d38f
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/4d696b13-86f2-4c9d-be0d-95b293430047/1fa9329f-0cec-4a2f-80e8-e26dbae3142e/ODGOKcj
Replit-Helium-Checkpoint-Created: true
2026-06-06 10:11:36 +00:00

52 lines
1.9 KiB
Bash
Executable File

#!/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://<user>:<token>@<gitea-host>/<owner>/<repo>.git
# # or via SSH:
# git remote add gitea git@<gitea-host>:<owner>/<repo>.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} <GITEA_REPO_URL>" >&2
echo " Or re-run with the URL inline:" >&2
echo " GITEA_REMOTE_URL=<GITEA_REPO_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