From 41e897f4945aaf8fbcdf0b12ac2f08c5e6ae0458 Mon Sep 17 00:00:00 2001 From: doc Date: Mon, 30 Jun 2025 20:11:52 +0000 Subject: commit of legacy code --- giteapushv3.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 giteapushv3.sh (limited to 'giteapushv3.sh') diff --git a/giteapushv3.sh b/giteapushv3.sh new file mode 100755 index 0000000..c2eb40f --- /dev/null +++ b/giteapushv3.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Genesis Radio Git Auto-Push +# With Auto-Retry if Push Fails + +# Move to the top of the git repo automatically +cd "$(git rev-parse --show-toplevel)" || { echo "❌ Not inside a Git repo. Exiting."; exit 1; } + +# Log the current location +echo "📂 Working in $(pwd)" + +# Stage all changes (new, modified, deleted) +git add -A + +# Check if there's anything to commit +if ! git diff --cached --quiet; then + TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S") + git commit -m "Auto-commit from giteapush.sh at $TIMESTAMP" + + echo "📡 Attempting to push to origin/main..." + + # Push with retry up to 3 times + tries=0 + max_tries=3 + until git push origin main; do + tries=$((tries+1)) + if [ "$tries" -ge "$max_tries" ]; then + echo "❌ Push failed after $max_tries attempts. Manual intervention needed." + exit 1 + fi + echo "âš ī¸ Push failed. Retrying ($tries/$max_tries) in 5 seconds..." + sleep 5 + done + + echo "✅ Changes committed and pushed successfully at $TIMESTAMP" +else + echo "â„šī¸ No changes to commit." +fi + +# Always show repo status at the end +echo "📋 Repo status:" +git status -sb -- cgit v1.2.3