I currently have a bot which automates a few GitHub operations, like merging pull requests, notifying staff on Slack when a PR is opened, that kind of thing (it\'s a custom flav
My company uses Github enterprise.
This API Docs link helped
GET /repos/:owner/:repo/collaborators/:username
If user has access you would get a response similar to
Status: 204 No Content
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
UPDATE: there is now a GitHub API endpoint for this:
https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
OLD ANSWER: There isn't a much simpler way to do this currently (but I agree that it would be great if there was a more elegant way to get this information). You could perhaps reduce the number of requests by fetching the user's teams and the list of teams which have access to the repository (and not all teams in the organizations). The intersection of these two lists should allow you to answer the question, I think.
(Also, in your solution, note that you not only have to check that the user is a member of a push-access team -- you also need to check that this push-access team has access to the repository in question. The user could have been a member of a push-access team which doesn't have access to the repository in question, and a member of a pull-access team which does have access to the repository in question.)