Automatic activation of repositories

Is there a way to automatically activate repositories as soon as they are created on github organization?

This functionality is not built-in to Drone but you can enhance Drone using its API. For example, you could create a small micro-service that receives organization webhooks [1] from GitHub, and then use the Drone API [2] to sync the repository list and activate [3] the repository.


1 Like

What is the endpoint for syncing the repository list?

Sorry, forgot to include the link. Use

It usually works but sometimes, I have to wait a couple of seconds before repo activation succeeds.

If this is something obvious and I’m just missing it, then sorry for the noise, but how would you automatically activate Gitea repositories?

In place of a GitHub Organization, I have a small Gitea server. The server serves the same security boundary as an Organization: only people on the server can interact with private repos, push code and data, etc. I want all repositories on the server to be automatically run through CI. I have a template repo with a template .drone.yml file, but they don’t do anything unless someone logs in to Drone and Activates each new repo. This is bug-prone, especially for my target audience – who are not even that comfortable with the command line, much less devops. I want to give them as gentle an introduction to the concept as possible.

I could force all users on the server into a single Gitea Organization, and use the same solution as for GitHub above, but this seems unnecessarily limiting.

The closest I’ve come is:

  1. Create a Gitea account that is an Owner of all Organizations and Repositories
  2. Get the DROKE_TOKEN its matching Drone’s account
  3. Run (export DRONE_TOKEN=$token; (drone repo sync | xargs -n 1 drone repo activate)), in a cronjob

The cronjob isn’t great because it’ll get slower and slower as more repositories are added over time, but I guess I could replace that with with a webhook that runs drone repo activate once per repository.

But the bigger problem is the the global account. Configuring it is tedious and fragile. I can probably make it happen by API, but even that is pretty fragile, and then I have an inexplicable dummy account that surely some of my users will notice and remove from their projects, causing another breakdown.

Instead, I’d like to just grant all of Drone access to all of Gitea. Can I?

1 Like