2

Issue

From this answer, I learned that one can normally set the build status of a commit using something like:

https://api.github.com/repos/[owner]/[repository]/statuses/[commit sha]

However, since I do not own the repositories of which the pull request is incoming, I cannot set the build status of their commits. Hence, I was wondering whether it was possible to (use the GitHub API to) set the build status of an incoming pull request instead.

Question

Suppose one uses a self-hosted CI, that automatically runs a build on each incoming pull request, how could one set the accompanying build status on the pull request in GitHub?

Note

From the given answer and comments by VonC I can derive that the default "pull request build status" is the build status that belongs to the commit of the incoming pull request. And that the only way to change the build status is to either acquire collaborator status on the random/other repository, or to become owner of the random/other repository. However, my question is: is it possible to override/set a manual build status belonging to a pull request, instead of belonging to the incoming commit?

I've included a sketch to illustrate the difference, as I thought my verbal explanation was insufficient. The blue line represents the default way a pull request gets a build status. (By making the person who receives the pull request, owner or collaborator on the incoming random repository.) My question (in terms of the image) is: does there exist that red box in the pull request that allows the owner of the repository that is receiving a pull request to set/override the build status belonging to the pull request (instead of belonging to the commit build status)?enter image description here

Based on the following part of a comment by VonC:

PR don't have exactly a "build status", only commit status or "status check"

I think I can conclude the answer to this question (in terms of the image) is: No.

a.t.
  • 2,002
  • 3
  • 26
  • 66

1 Answers1

2

However, since I do not own the repositories of which the pull request is incoming

That means you would not be able to modify anything in that repository though: no commit status (2012) or even check API (2017).

You would need to be a collaborator on that repository to do anything on it.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you! I assumed it would not be possible to change anything about the repository on their side. Thank you for providing means with which that does become possible (collaborator status). Do you mean to imply that it is currently not possible to (manually) set a build status on an incoming pull request (regardless of the other repository)? – a.t. Feb 13 '22 at 08:24
  • 1
    @a.t. If you are owner or collaborator, you should be able to set a commit status on a PR PR don't have exactly a "build status", only commit status or "status check": see https://github.com/cloudposse/github-status-updater for example. – VonC Feb 13 '22 at 11:17