-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to link back to the PR (GitHub commit status / Check API) #22
Comments
Closing because I misdiagnosed the issue -- it was actually GitHub giving me an unexpected GITHUB_SHA. |
@elliot-nelson How did you end up resolving this? I'm running into the same issue and can't figure out how to get Azure Pipelines to post commit status on the PR. Thanks so much for your help! 🙇🏽 |
Hi there @mnquintana! So, in my case, we were triggering an Azure pipeline on-demand from a PR comment, and using a GitHub Action "issue" event. Because the GITHUB_REF in this case is a "merged" commit and not actual head commit of the branch you're merging, the check at the end doesn't show up. To fix this we ended up making a tiny GitHub Action to go and retrieve the Head Branch REF (name) and SHA (commit hash) from the GitHub REST API. Once you retrieve it, you can pass that REF and SHA to the Azure Pipeline and everything works as expected. (The action above works for our use case, there may be other similar actions that you could also use depending on the specifics of your workflow.) |
@elliot-nelson Ahh got it, that makes sense! How did you end up passing the correct ref and SHA to Azure Pipelines with this action? Or did you end up having to call Azure Pipelines' API directly instead? |
@mnquintana I put up a PR for the official pipelines plugin (#23), and in fact that PR includes an example of how you could do it just inline in your workflow. (We ended up wrapping it in a separate Action because that inline javascript gets rather hard to edit and test, it's very easy to break your workflow, and you can't test without merging to main/master because it's an issue-level event. But that's the quick-and-dirty way!) Unfortunately there hasn't been any activity on the PR yet, so right now we're using my fork in our CI pipeline. Eventually we'll either get the change merged upstream, or I guess officially fork into a company repo (but hoping for the former). |
If you define a normal Azure pipeline (triggering on
trigger:
orpr:
), as it finishes it automatically adds the link to the finished build under the checks/statuses section of the PR.However, if I use
Azure/pipelines@v1
to trigger an Azure pipeline from a GitHub Action, it does not push back any kind of commit status on completion. Is there a way to pass either the relevant commit ref or PR number to the Azure build, so that when it finishes it can post back a Check?That would be ideal; if it's not possible, I guess I can do it myself, but I still need to then somehow pass the PR number as a "parameter" to the Azure build, and then use that PR number to write something in my own pipeline yaml to call back to GitHub (maybe using the GitHub REST API). I'd be interested in any examples of something like that.
The text was updated successfully, but these errors were encountered: