Skip to content

Instantly share code, notes, and snippets.

@CherryKitten
Created June 21, 2023 09:09
Show Gist options
  • Save CherryKitten/96b70ea424a31f23c7fe42b94bcf4886 to your computer and use it in GitHub Desktop.
Save CherryKitten/96b70ea424a31f23c7fe42b94bcf4886 to your computer and use it in GitHub Desktop.
Create Forgejo Mirrors for Github stars
#/!/bin/bash
# Dependency: jq & curl
# env vars:
# GITHUB_USER
# FORGEJO_USER
# FORGEJO_TOKEN (password or api token)
# FORGEGO_URL
curl https://api.github.com/users/$GITHUB_USER/starred\?per_page\=100\&page\=1 \
| jq -r '.[] | [.name, .html_url] | @tsv' |\
while i=$'\t' read -r name url; do
curl \
-u $FORGEJO_USER:$FORGEJO_TOKEN \
-X POST \
-H "Content-Type: application/json" \
--data "{\"clone_addr\": \"$url\", \"repo_name\": \"$name\", \"mirror\": true, \"repo_owner\": \"Mirrors\"}" \
$FORGEJO_URL/api/v1/repos/migrate; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment