| completions | feat(completions): Shell completions for fish shell | |
| test | feat(packages): Add repo packages command, to manage Docker registry | |
| .env.example | Initial code | |
| .gitignore | Initial commit | |
| COMPLETIONS.md | feat(completions): Shell completions for fish shell | |
| 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 | |
| LICENSE | Initial commit | |
| package-lock.json | fix(repo-script): Get all orgs before trying to find a specific org | |
| package.json | fix(repo-script): Get all orgs before trying to find a specific org | |
| README.md | s/ForgeJo/Forgejo/ | |
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
- Clone this repository.
- Run
npm installto install dependencies. - 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:
-
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.
-
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.
-
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.
-
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!