#!/bin/bash # Push to Remote - Choose between GitHub and Gitea # This script lets you choose which remote to push to set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' NC='\033[0m' # No Color echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "${BLUE}║ Portfolio - Push to Remote ║${NC}" echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}" echo "" # Get current branch CURRENT_BRANCH=$(git branch --show-current) echo -e "${CYAN}Current branch: ${CURRENT_BRANCH}${NC}" echo "" # Check available remotes echo -e "${BLUE}Available remotes:${NC}" git remote -v | grep -E "(origin|gitea)" | head -4 echo "" # Ask which remote to push to echo -e "${YELLOW}Where do you want to push?${NC}" echo " 1) GitHub (origin) - https://github.com/denshooter/portfolio.git" echo " 2) Gitea (gitea) - https://git.dk0.dev/denshooter/portfolio.git" echo " 3) Both" echo "" read -p "Choose (1/2/3): " -n 1 -r REMOTE_CHOICE echo "" case $REMOTE_CHOICE in 1) REMOTE_NAME="origin" REMOTE_DESC="GitHub" ;; 2) REMOTE_NAME="gitea" REMOTE_DESC="Gitea" ;; 3) REMOTE_NAME="both" REMOTE_DESC="Both (GitHub and Gitea)" ;; *) echo -e "${RED}✗ Invalid choice${NC}" exit 1 ;; esac echo "" echo -e "${BLUE}📋 Pushing to ${REMOTE_DESC}...${NC}" echo "" # Function to push to a remote push_to_remote() { local remote=$1 local desc=$2 echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e "${BLUE}🚀 Pushing to ${desc} (${remote})...${NC}" if git push "$remote" "$CURRENT_BRANCH"; then echo -e "${GREEN}✓ Successfully pushed to ${desc}!${NC}" return 0 else echo -e "${RED}✗ Push to ${desc} failed${NC}" return 1 fi } # Push based on choice SUCCESS=true if [ "$REMOTE_NAME" = "both" ]; then push_to_remote "origin" "GitHub" || SUCCESS=false echo "" push_to_remote "gitea" "Gitea" || SUCCESS=false else push_to_remote "$REMOTE_NAME" "$REMOTE_DESC" || SUCCESS=false fi echo "" if [ "$SUCCESS" = true ]; then echo -e "${GREEN}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "${GREEN}║ Successfully Pushed! 🎉 ║${NC}" echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}" echo "" echo -e "${BLUE}📊 Latest commits:${NC}" git log --oneline -3 echo "" else echo -e "${RED}✗ Some pushes failed. Check the errors above.${NC}" exit 1 fi echo -e "${GREEN}✅ Done!${NC}"