1
2
Fork
You've already forked repo
1
A tool for quickly provisioning organizations and repos on a Forgejo / Gitea server.
  • JavaScript 94.7%
  • Shell 5.3%
2025年12月11日 13:36:46 -08:00
completions feat(completions): Shell completions for fish shell 2025年12月11日 13:35:14 -08:00
test feat(packages): Add repo packages command, to manage Docker registry 2025年08月29日 19:09:50 -07:00
.env.example Initial code 2023年10月29日 11:46:06 -07:00
.gitignore Initial commit 2023年10月29日 18:40:50 +00:00
COMPLETIONS.md feat(completions): Shell completions for fish shell 2025年12月11日 13:35:14 -08:00
index.js feat(orgs,packages): Lots of new functionality around copying over branch protections to new repos, adding support for configuring your api key, and package listings to prune old docker images 2025年12月11日 13:36:46 -08:00
LICENSE Initial commit 2023年10月29日 18:40:50 +00:00
package-lock.json fix(repo-script): Get all orgs before trying to find a specific org 2024年12月07日 13:17:12 -08:00
package.json fix(repo-script): Get all orgs before trying to find a specific org 2024年12月07日 13:17:12 -08:00
README.md s/ForgeJo/Forgejo/ 2023年10月29日 20:11:17 +00:00

Repo tool for Forgejo/Gitea

This is a node script to quickly provision organizations and repositories within a Forgejo or Gitea server, provisioning teams within an organization and branch protections within a repository from an example in a specific org/repository.

Requirements

  • NodeJS 14+ (or another JS runtime that supports ES modules).
  • An account on a Forgejo/Gitea server with permission to create organizations on the server.
  • An organization set up with teams defined that you want copied into new organizations.
  • A repository set up, optionally with branch protections you would like on new repositories.

Dependencies

Installation

  1. Clone this repository.
  2. Run npm install to install dependencies.
  3. Create a ".env" file, setting values for the variables listed in .env.example.

Notes

DEFAULT_TEAMS - you can add multiple teams to the new org, separated by a comma. DO NOT add "Owners" to this list, because the new organization automatically creates an Owners team. This script will set up each of the specified teams with exactly the same permissions as they have in your DEFAULT_ORG, and then add all of the members to the new team that are in that team in the default org.

DEFAULT_OWNERS - You can specify any number of user accounts to add to the new "Owners" team in the new organization. Separate multiple user accouts with a comma.

Usage

You can verify that everything is set up correctly and get a list of users by running:

./index.js teams list

If everything is successful, you will see a dump of the specified teams, with a member list and team configuration.

./index.js create <new org name> [new repo name]

This command first checks to see if exists as an organization in your server. If it does not, it creates the new org, creates new teams within the org, and adds users to the org.

Then, if a repo is specified, it checks to see if that repo already exists in the org, and if it does not, it creates it and copies the branch protections from the DEFAULT_ORG/DEFAULT_REPO repository.

It is safe to run these commands if your org/repo already exists, the script currently ignores any existing orgs and repos.

Roadmap

We see a couple other use cases that we will need to add at some point in the future:

  1. Add new users to existing teams. As we bring on new developers, we need a quick way to give them access to all of the organizations on our server.

  2. Remove users from existing teams. If we have a member leave our team, we would like to be able to quickly bulk remove them from all existing organizations.

  3. Update branch protections. As we refine/change our processes, we might want to change some branch protection rules, and be able to update most of the repos on the site with the new rules. Some of our repos are for tools that have a different release process, though, so we will need to define a way to know which repos need our defined set of branch protections.

  4. Better error handling, better usage. This is not a tool we need to run very often, so we got this working just well enough to create the dozens of orgs and repos we needed to migrate, so for a couple hours of coding, we saved several days of setup work. PRs welcome!