Reputation: 2508
According to this question a PR is just an issue with some things on top.
How to get the associated issue id?
I just saw issue_url as attribute for the pull request object.
Also, PR has the method create_review_comment
but no method create_issue_comment
.
How would such a method look like?
How to create an issue comment in the Pull Request?
Upvotes: 4
Views: 4336
Reputation: 1254
This works for me with current pygithub:
from github import Github
g = Github(GITHUB_TOKEN)
repo_name = 'Org/repo'
repo = g.get_repo(repo_name)
pr = repo.get_pull(PR_NUMBER)
pr.create_issue_comment('test')
Upvotes: 9
Reputation: 2508
I was able to do it by getting the issue from the PR number. Indeed, in github a "hidden" issue is created every time you create a pull request.
So the following code worked:
gh = ... # Connection
repo = gh.repository(user, repo_name)
pr = repo.create_pull(description, base, from_branch, detailed)
issue = repo.issue(pr.number)
issue.create_comment(comment)
One could also use other ways to get the issue from PR number.
Not sure if there is any way more straightforward than this
Upvotes: 8