init
This commit is contained in:
commit
4ec9ee15aa
1 changed files with 42 additions and 0 deletions
42
syncRepos.sh
Executable file
42
syncRepos.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/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"
|
Loading…
Reference in a new issue