githubgithub-actionsgithub-webhook

Automate Creation of Github Topics During Repository Initialization


In regards to Github Topics: https://docs.github.com/en/github/administering-a-repository/classifying-your-repository-with-topics

Is there a way to automate the creation of these topics/tags? For example, when a repository within the organization is initialized, I want to get that event via a webhook and then automatically add a Topic called - "abc-repo". Is it possible to do something like this?

I've been reading and haven't seen a way to automate this process. It appears they are just added via the Github interface from within the repository itself.


Solution

  • The topics can be set using the repositories REST API. If you create the repository via the API, you can pass the topics element with a list of topics you'd like, or you can update an existing repository using a PATCH request.