'How to add a topic to a GitHub repo using a GitHub Action?

Is there a way to add a topic to a repository using a GitHub Action running within that same repository? The idea is you would push code with the .github/workflows/add-topic.yml which would ensure the repo has topic foo every time the action runs.

I realize you can do this via the GitHub API, but that requires credentials (i.e. adding a personal access token as a repository secret), which I'm trying to avoid.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source