Search code examples
githubgithub-actions

How to get workflow id using gh workflow run cli?


How to get workflow id using gh workflow run gh cli?

This currently is not working for me:

RUN_ID=$(gh workflow run workflow.yml --repo $REPO --ref $REF \
            -f param=$par| jq -r '.id')

Solution

  • I don't think you can get the ID from the run command, you need to get it after you queued it with the list command:

    RUN_ID=$(gh run list --json databaseId --workflow= workflow-bot.yml --limit 1 | jq -r '.[0].databaseId')
    

    The databaseId is the run id.