#!/bin/bash
# Script to push commits to GitHub after SSH key is added

set -e

echo "=== GitHub Push Script ==="
echo ""

# Check SSH authentication
echo "Testing SSH connection to GitHub..."
if ssh -T git@github.com 2>&1 | grep -q "successfully authenticated"; then
    echo "✓ SSH authentication successful"
    echo ""
    echo "Pushing commit to GitHub..."
    git push
    echo ""
    echo "✓ Successfully pushed to GitHub!"
    echo ""
    echo "Commit details:"
    git log --oneline -1
else
    echo "✗ SSH authentication failed"
    echo ""
    echo "Please add your SSH key to GitHub:"
    echo "1. Visit: https://github.com/settings/keys"
    echo "2. Click 'New SSH key'"
    echo "3. Title: 'WSL2 - the-order-monorepo'"
    echo "4. Paste this public key:"
    echo ""
    cat ~/.ssh/id_ed25519.pub
    echo ""
    echo "5. Click 'Add SSH key'"
    echo "6. Run this script again: ./scripts/push-to-github.sh"
    exit 1
fi

