Mass delete repos from Forgejo, Gitea, or Codeberg

CAUTION: There is no confirmation when deleting the repos.

First, you need an access token, which you can generate under User Settings -> Applications. Make sure it has at least read and write access for repository and user.

Delete select repos

#!/usr/bin/env bash

set -euo pipefail

# Change the values below to your own. The values below are just examples.
INSTANCE_URL=https://codeberg.org
INSTANCE_USER=hyperreal
INSTANCE_TOKEN=cd188e90f2f03eed57b1971fb16329b1b919a2bb

# Add the repository names to an array. E.g., if your repo is located at
# https://codeberg.org/hyperreal/dotfiles, the name you would add would be "dotfiles".
repos=("repo0" "repo1" "dotfiles" "repo2")

# Iterate through the array and delete each item using curl.
for repo in "${repos[@]}"; do
echo "Deleting repository: ${repo}"
curl -s \
-u "${INSTANCE_USER}:${INSTANCE_TOKEN}" \
-X DELETE \
"${INSTANCE_URL}/api/v1/repos/${INSTANCE_USER}/${repo}"
done

echo "All your repos are belong to internet abyss! Arrivederci, baby!"

Delete all the repos

If for whatever reason you want to delete all the repos on your account, change the line with the repos=("repo0" "repo1" "dotfiles" "repo2") array to the following.

readarray -t repos < <(curl -s -u "${INSTANCE_USER}:${INSTANCE_TOKEN} "${INSTANCE_URL}/api/v1/users/${INSTANCE_USER}/repos?limit=100" | jq -r '.[].name')