Web3CV/migrate-to-gitea.sh

52 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# This script helps migrate your repository from GitHub to your self-hosted Gitea
# First, check if we can connect to the Gitea server
echo "Testing connection to Gitea server..."
if ! ssh git@git.boilerhaus.org "echo 'Connection successful'"; then
echo "Failed to connect to Gitea server. Please check your SSH configuration."
exit 1
fi
# Create a new repository on Gitea using the API instead of CLI
echo "Creating a new repository on Gitea..."
# We'll use curl to create the repository via the API
# You'll need to generate an API token from your Gitea instance
# Generate one at https://git.boilerhaus.org/user/settings/applications
read -p "Enter your Gitea API token: " API_TOKEN
if [ -z "$API_TOKEN" ]; then
echo "API token is required. Please generate one at https://git.boilerhaus.org/user/settings/applications"
exit 1
fi
curl -X POST "https://git.boilerhaus.org/api/v1/user/repos" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: token $API_TOKEN" \
-d "{\"name\":\"Web3CV\",\"description\":\"My Web3 CV website\",\"private\":false,\"auto_init\":false}"
# Wait a moment for the repository to be created
sleep 2
# Add Gitea as a new remote
echo "Adding Gitea as a new remote..."
git remote add gitea git@git.boilerhaus.org:boilerrat/Web3CV.git
# Verify the remote was added
echo "Verifying remote..."
git remote -v
# Push all branches and tags to Gitea
echo "Pushing all branches and tags to Gitea..."
git push --all gitea
git push --tags gitea
# Set Gitea as the default remote
echo "Setting Gitea as the default remote..."
git remote rename origin github
git remote rename gitea origin
echo "Migration to Gitea complete!"
echo "Your repository is now available at: https://git.boilerhaus.org/boilerrat/Web3CV"