Add repository created by Github App to Github App repository access #72593
-
Hi! I want to develop a GitHub App that can create a repository from a specified template and then performing some actions on that repository (e.g. a adding secrets, workflows). I am facing the following problem. Suppose a user that installs and authorizes my app decides to not give permission for all repositories, and chooses just some repositories from their account. In that case, my app will successfully create a new repository from the specified template using an user access token. Still, it will fail to further modify the repository (commit a file update) because it is not in the repository access list of the GitHub App. What I want to achieve is to automatically add repositories created by the GitHub App to the repository permission list of that app. I found an API endpoint for adding a repo to an installation ( Upon researching this issue, I found the Vercel Github App, that successfully does exactly what I described, but I can't figure out how they do this. I looked at permissions requested by their app and mine I think I have all the necessary permissions for this task.
I would really appreciate any advice regarding this. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Any resolutions on this? |
Beta Was this translation helpful? Give feedback.
-
Still running into this today, even when creating an empty repo (with PyGithub). Any ideas? |
Beta Was this translation helpful? Give feedback.
I found a solution. Apparently, if you create a blank repository using a GitHub App, that repository is automatically added to the app's permissions list. I was trying to create a repository using a template, and it looks like this endpoint doesn't add the newly created repo to the app permission list.
The solution was to create a blank repository in order to be accessible by the app. After that, I was able to use the GitHub API to make changes to that repository. However, because I wanted to initialize the repository with a template, I couldn't make use of the API, so I had to programmatically clone the repository and push my template as an initial commit.