From b05c8b727f80cdbb1e152e66e1366d03bf4c80a9 Mon Sep 17 00:00:00 2001 From: CherryKitten Date: Sat, 9 Mar 2024 11:55:43 +0100 Subject: [PATCH] Initial commit :3 --- README.md | 3 +++ github_star_mirror.sh | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 README.md create mode 100755 github_star_mirror.sh 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