API for accessing inputs of workflow dispatch run

Hi,

We trigger workflow dispatch with a set of inputs. This results in workflow runs and workflow jobs.

Currently, GitHub API has endpoints for getting runs and jobs. But none of them contain the inputs of the workflow dispatch that triggered the run/jobs in the first place.

I wonder if there is some other endpoint that could be used for obtaining the inputs of a workflow run (when the run is of type workflow_dispatch).

4 Likes

I would love to see the dispatch endpoint return a run_id rather than 204 No Content. Right now there’s no good way to associate a trigger with the run and jobs it creates other than scraping. And as @scriptnull said, that’s difficult if the runs don’t store info about the inputs they were triggered with.

2 Likes

I agree, this seems like a bit of a gap in the API in that you cannot link the workflow_dispatch event to the resulting workflow run. I also had the same idea of putting a correlation id as one of the inputs so that I could go through the list of runs to try and match it up with the event, but the inputs to the run cannot be extracted

@scriptnull @kaiku @davidbairdala 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

on:
  workflow_dispatch:
    inputs:
      id:
        description: 'run identifier'
        required: false
jobs:
  id:
    name: Workflow ID Provider
    runs-on: ubuntu-latest
    steps:
      - name: ${{github.event.inputs.id}}
        run: echo run identifier ${{ inputs.id }}

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