42 lines
1.2 KiB
Bash
Executable file
42 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# CONFIGURATION
|
|
GITHUB_USER="nomadics9"
|
|
FORGEJO_USER="nomad"
|
|
FORGEJO_URL="git@git.askar.tv"
|
|
FORGEJO_API="https://git.askar.tv/api/v1"
|
|
FORGEJO_TOKEN="TOKEN"
|
|
TMP_DIR="github-to-forgejo"
|
|
|
|
mkdir -p "$TMP_DIR"
|
|
cd "$TMP_DIR" || exit 1
|
|
|
|
# 🧠 Fetch public GitHub repos via API
|
|
repos=$(curl -s "https://api.github.com/users/$GITHUB_USER/repos?per_page=1000" |
|
|
jq -r '.[] | "\(.name) false"') # Always false = public
|
|
|
|
# 📦 Select repos
|
|
selected=$(echo "$repos" | fzf --multi --prompt="Select repos to sync: ")
|
|
[ -z "$selected" ] && echo "No repos selected. Exiting." && exit 1
|
|
|
|
# 🔁 Clone & Push
|
|
while read -r line; do
|
|
name=$(echo "$line" | awk '{print $1}')
|
|
echo "==> Syncing $name..."
|
|
|
|
# Clone from GitHub
|
|
git clone --mirror "https://github.com/$GITHUB_USER/$name.git"
|
|
cd "$name.git" || continue
|
|
|
|
# Create on Forgejo
|
|
curl -s -X POST "$FORGEJO_API/user/repos" \
|
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"name\":\"$name\",\"private\":false,\"auto_init\":false}"
|
|
|
|
# Push to Forgejo
|
|
git remote add forgejo "$FORGEJO_URL:$FORGEJO_USER/$name.git"
|
|
git push --mirror forgejo
|
|
|
|
cd ..
|
|
done <<< "$selected"
|