Re-trigger failed Workflow for PRs on External Events

Hi There,

Is there a recommended way to re-trigger a failed workflow on a PR using Github API? We have a bot for adding labels and triggering our own CI, but it is not able to re-run the workflow from Github Actions.
repository_dispatch is likely the event but it only works on master/default branch. I saw there was feature request for enabling repository_dispatch to trigger workflow on any branches, how can I track this feature?

Thanks

Hi @ys2843,

Glad to see you in Github Community Forum!

It’s supported to rerun failed workflow run from rest api, code sample as below:

curl -X POST -u admin:${{ secrets.PAT }} https://api.github.com/repos/{org}/{reponame}/actions/runs/{checkrunid}/rerun

Please check the link for the details. To rerun the workflow, only checkrunid is needed, not the branch name.

repository_dispatch is an ‘external’ event which needs to put it on master branch, if you’d like to work for other branches, you can checkout the specified branch, code sample as below:

on: [repository_dispatch]
jobs:
  job1:
    runs-on: ubuntu-latest
    steps:
      - name: checkout other branch
        uses: actions/checkout@v2
        with:
          repository: 'dev'               # checkout the desired branch.

If you’d like to re-run workflow with repository_dispatch event, you can add the checkrunid in the payload. Please check the action ‘peter-evans/repository-dispatch’ about how to transfter the payload and get the value.

Of course, if you have any feedback or feature_request, you can raise a ticket here where github product manager will take a review.

Hope it’s clear and helpful!