Files
memefast/push.sh
2025-05-28 12:59:01 +08:00

39 lines
1.0 KiB
Bash

#!/bin/bash
# Function to prompt for branch if not provided
prompt_for_branch() {
while true; do
read -p "Enter branch name (e.g. main, staging, sandbox): " branch
if [[ "$branch" == "main" || "$branch" == "staging" || "$branch" == "sandbox" ]]; then
echo "$branch"
break
else
echo "Invalid branch name. Please enter 'main' or 'staging' or 'sandbox'."
fi
done
}
# Check if branch parameter is provided
if [ $# -eq 0 ]; then
echo "Branch parameter is missing."
branch=$(prompt_for_branch)
else
branch=$1
# Validate the provided branch name
if [[ "$branch" != "main" && "$branch" != "staging" && "$branch" != "sandbox" ]]; then
echo "Invalid branch name. Using prompt to get correct branch name."
branch=$(prompt_for_branch)
fi
fi
# Add all changes
git add .
# Commit with the message "Update"
git commit -m "Update"
# Push to the specified branch
git push origin "$branch"
echo "Changes pushed to $branch branch."