GithubHelp home page GithubHelp logo

Comments (3)

eric-labelle avatar eric-labelle commented on August 17, 2024 2

I am also wondering the same thing. The status check on PRs in Github are based on workflow actions, but the workflow (which only triggers an Azure DevOps pipeline) is always Valid as soon as it successfully launched the Azure DevOps pipeline, even if the ADO pipeline fails or finishes minutes later as you mentioned. Still haven't found a way to get the status.

EDIT: Actually found a way. At the end of your Azure pipeline triggered by GitHub's Action, you can add a POST call to Github's REST API to add a status on the commit that will prevent you from merging in case the build completed in a failure :) https://developer.github.com/v3/repos/statuses/#create-a-status

from pipelines.

spowser avatar spowser commented on August 17, 2024

In the case of waiting for AzDO to finish before the status is returned to Github, would you be paying for 2 agents at that point? GitHub agent kicks off AzDO and sits there doing nothing but still accumulating minutes on your bill?

from pipelines.

tjcorr avatar tjcorr commented on August 17, 2024

Yes this is designed to fire asynchronously. If you sat waiting for the ADO pipeline to finish you would be paying for 2x the compute. The recommend approach here would be to have the ADO pipeline open a new status check at the beginning of the pipeline and then mark it as pass/fail at the end. Here is a minimal sample ADO yaml pipeline:

trigger: none

variables:
  BUILD_URL: '$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)'
  CHECK_NAME: 'ADO/pipeline'

pool:
  vmImage: ubuntu-latest

steps:
- script: |
    curl -X POST -H "Authorization: Bearer $(GITHUB_PAT)" https://api.github.com/repos/$(GITHUB_REPO)/statuses/$(GITHUB_SHA) -d '{"state":"pending","target_url":"$(BUILD_URL)","description":"Pending security checks","context":"$(CHECK_NAME)"}'
  displayName: 'Create a new status check on a github repo'

- script: echo 0
  displayName: 'Insert your code here'

- script: |
    curl -X POST -H "Authorization: Bearer $(GITHUB_PAT)" https://api.github.com/repos/$(GITHUB_REPO)/statuses/$(GITHUB_SHA) -d '{"state":"success","target_url":"$(BUILD_URL)","description":"ADO Pipeline passed","context":"$(CHECK_NAME)"}'
  displayName: 'Mark status as success'

- script: |
    curl -X POST -H "Authorization: Bearer $(GITHUB_PAT)" https://api.github.com/repos/$(GITHUB_REPO)/statuses/$(GITHUB_SHA) -d '{"state":"failure","target_url":"$(BUILD_URL)","description":"ADO Pipeline failed","context":"$(CHECK_NAME)"}'
  displayName: 'Mark status as failure'
  condition: failed()

This would require that you pass a few variables into the pipeline like

  • GITHUB_PAT: A GitHub PAT with the repo:status scope to create/update status checks
  • GITHUB_SHA: The commit to annotate with the status check. From GitHub this would be ${{ github.sha }} for a branch or ${{ github.event.pull_request.head.sha }} for a PR.
  • GITHUB_REPO: The full owner/repo_name of the GitHub repo. This would equate to ${{ github.repository }}

from pipelines.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.