Skip to content

Instantly share code, notes, and snippets.

@jettero
Created April 17, 2022 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jettero/cc6610ce6549d2c03222ad14c99a4fa1 to your computer and use it in GitHub Desktop.
Save jettero/cc6610ce6549d2c03222ad14c99a4fa1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# simple jq task: reduce list of objects with by workflow_id and job id
# into a object { workflow_id => [list of job ids] }
#
# .o(this seriously took like 2 whole hours ot figure out)
gh api repos/$owner_slash_repo/actions/runs?per_page=100 \
| jq '[ .workflow_runs | group_by(.workflow_id)[] | {(.[0].workflow_id|tostring): [ .[] | .id ]} ]
| reduce .[] as $item ({}; . * $item)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment