commit b05c8b727f80cdbb1e152e66e1366d03bf4c80a9 Author: CherryKitten Date: Sat Mar 9 11:55:43 2024 +0100 Initial commit :3 diff --git a/README.md b/README.md new file mode 100644 index 0000000..908d3ce --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Scripts + +collection of simple small scripts that don't really need their own repo diff --git a/github_star_mirror.sh b/github_star_mirror.sh new file mode 100755 index 0000000..aeb35a7 --- /dev/null +++ b/github_star_mirror.sh @@ -0,0 +1,20 @@ +#/!/bin/bash + +# Gets the 100 most recently starred repositories of $GITHUB_USER, and creates Mirrors on $FORGEJO_URL +# Dependencies: jq & curl +# env vars: +# GITHUB_USER +# FORGEJO_USER +# FORGEJO_TOKEN (password or api token) +# FORGEJO_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