Some checks failed
CI / test-and-build (push) Failing after 1m40s
Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
857 B
Bash
28 lines
857 B
Bash
#!/usr/bin/env bash
|
|
# Turn ~/games_app tarball into a git checkout of Gitea main while preserving .env and Docker state.
|
|
set -euo pipefail
|
|
APP="${HOME}/games_app"
|
|
TOKEN_FILE="${HOME}/gitea-push-credentials.txt"
|
|
TOKEN="$(grep -A1 'Push token' "$TOKEN_FILE" | tail -1 | tr -d ' \r')"
|
|
URL="http://tloto-admin:${TOKEN}@127.0.0.1:3000/tloto-admin/games_app.git"
|
|
|
|
cd "$APP"
|
|
cp -a .env /tmp/games_app.env.bak
|
|
if [[ ! -d .git ]]; then
|
|
git init -b main
|
|
git remote add origin "$URL"
|
|
else
|
|
git remote remove origin 2>/dev/null || true
|
|
git remote add origin "$URL"
|
|
fi
|
|
git fetch origin main
|
|
git checkout -f -B main origin/main
|
|
# restore secrets
|
|
cp -a /tmp/games_app.env.bak .env
|
|
chmod 600 .env
|
|
# sanitize remote URL (no token)
|
|
git remote set-url origin "http://127.0.0.1:3000/tloto-admin/games_app.git"
|
|
git status -sb
|
|
git rev-parse --short HEAD
|
|
echo "APP_GIT_OK"
|