Web3CV/migrate-to-gitea.sh

52 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# This script helps migrate your repository to your self-hosted Gitea
# First, check if we can connect to the Gitea server
echo "Testing connection to Gitea server..."
if ! curl -s https://git.boilerhaus.org > /dev/null; then
echo "Failed to connect to Gitea server. Please check your network connection."
exit 1
fi
# Create a new repository on Gitea using the API
echo "Creating a new repository on Gitea..."
# 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
# Reset remotes
echo "Resetting remotes..."
git remote remove origin 2>/dev/null || true
git remote remove github 2>/dev/null || true
git remote remove gitea 2>/dev/null || true
# Add Gitea as the only remote
echo "Adding Gitea as the remote..."
git remote add origin https://git.boilerhaus.org/boiler/Web3CV.git
# Verify the remote was added
echo "Verifying remote..."
git remote -v
# Push all branches and tags to Gitea
echo "Pushing to Gitea..."
git push -u origin main
git push --tags origin
echo "Migration to Gitea complete!"
echo "Your repository is now available at: https://git.boilerhaus.org/boiler/Web3CV"