diff --git a/push.sh b/push.sh new file mode 100755 index 0000000..99f2a83 --- /dev/null +++ b/push.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -e + +BRANCH="main" + +# Stop if not inside a git repo +git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { + echo "Not inside a git repository." + exit 1 +} + +# Check if there are changes +if [ -z "$(git status --porcelain)" ]; then + echo "No changes to commit." + exit 0 +fi + +# Random commit message +MSG="update-$(date +%Y%m%d-%H%M%S)-$RANDOM" + +echo "Using commit message: $MSG" + +git add . +git commit -m "$MSG" +git push origin "$BRANCH" + +echo "Done." \ No newline at end of file