How to get run_id after workflow_dispatch?

When I have multiple tasks running at the same time, it seems like I can’t get the run_id after I dispatch a workflow since the api only returns 204.

1 Like

Hi @leng-yue, welcome to the GitHub Support Community! There isn’t a direct way to get the run_id when triggering a workflow_dispatch event. The best thing you can do is to poll the list workflow runs endpoint and catch your workflow as it starts, though there’s not a guarantee on how quickly your workflow will start after being triggered.

@leng-yue I’ve found out that we can use an input to “track” the workflow run id. And put the input value in the name property like this:

name: ID Example

        description: 'run identifier'
        required: false
    name: Workflow ID Provider
    runs-on: ubuntu-latest
      - name: ${{}}
        run: echo run identifier ${{ }}

I’ve made a script in python that dispatch the workflow, get the workflow runs, get the jobs and extract the step name to compare with the initial input value.

Checkout this SO post: Get run id after triggering a github workflow dispatch event - Stack Overflow
Gist: Get the run_id associated to a dispatch in Github actions · GitHub