blob: c2eb40fcbe76d1dac4f8a268e578dabb18bc0525 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
|