Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 3

How to trigger a workflow on a specific PR via a webhook/repository_dispatch?

I’d like to have another system (Jira in my case) do a webhook POST to GitHub, where a specific PR will have GitHub Workflow actions rerun.

 

I see documentation on how to trigger a workflow with an external event, but nothing for how to target a specific PR.

 

The general flow I'm working with is:

  1. PR opened.
  2. GitHub workflow executes, where a check may fail (as desired) based on data from external system.
  3. External system data is updated.
  4. External system sends message to GitHub to trigger workflow to be rerun on that same PR (but not other open PR's on the same repo).

 

That step #4 is where I don't see much for options.  The link above looks somewhat promising, but I get the sense I'm missing something in using it or perhaps it's just the wrong thing for my use case.

2 Replies
Highlighted
GitHub Partner
Message 2 of 3

Re: How to trigger a workflow on a specific PR via a webhook/repository_dispatch?

@craig-landry ,

Actually, the repository_dispatch event generally is used to trigger a new workflow run from External, not re-run the failed run.

 

Your final goal is re-running the failed check with the updated external system data, right?

You can try the below methods:
1) Manually re-run the failed check via clicking the "Re-run jobs" button.

re-run_button.PNG
2) On the External system, execute the "Rerequest a check suite" API or the "Re-run a workflow" API.

 

NOTE: you can't only re-run the failed check (job in workflow) separately in a check-suite (workflow), you need to re-run the whole check-suite. The above two methods follow this rule.

Highlighted
Copilot Lvl 2
Message 3 of 3

Re: How to trigger a workflow on a specific PR via a webhook/repository_dispatch?

Thanks @BrightRan that "rerun" endpoint was just what I was looking for!