Skip to content

Instantly share code, notes, and snippets.

@guilbep
Created November 7, 2023 13:04
Show Gist options
  • Save guilbep/d8912a9277ca8be55fbba212ff809821 to your computer and use it in GitHub Desktop.
Save guilbep/d8912a9277ca8be55fbba212ff809821 to your computer and use it in GitHub Desktop.
Create issue with a batch script from a json and jq
#!/bin/sh
# Example of input
# {
# "id": "Module: Cooking",
# "sid": "f",
# "comment": "Ethanol: The tool does not indicate whether ethanol originates from renewable sources (which is likely the case as it commonly stems from plantations).",
# "priority": "Implemented",
# "actions": "IT4R implemented the tree icon indicating the ethanol comes from sustainable sources.",
# "estimated_hours": "0",
# "unhcr_comments": null,
# "ctobin111": null,
# "@me": null
# },
[ $# -ge 1 -a -f "$1" ] && input="$1" || input="-"
cat $input | jq -c '.[]' | while read name ; do
# echo $name |jq
id=$(echo $name | jq -r '.id')
sid=$(echo $name | jq -r '.sid')
priority=$(echo $name | jq -r '.priority')
comment=$(echo $name | jq -r '.comment')
actions=$(echo $name | jq -r '.actions')
estimated_hours=$(echo $name | jq -r '.estimated_hours')
unhcr_comments=$(echo $name | jq -r '.unhcr_comments')
ctobin111=$(echo $name | jq '.ctobin111')
me=$(echo $name | jq '.["@me"]')
# issue create --title "FEAT<ghg>: test" --body "test body" --label "bug,ghg" --assignee ctobin111,@me --project "UNHCR - TSS"
assignee_ctobin111=$([[ $ctobin111 == "null" ]] && echo "" || echo ",ctobin111")
body="<b>comment</b>: $comment<br/>\
<b>actions</b>: $actions<br/>\
<hr/>\
<b>estimated_hours</b>: $estimated_hours<br/>\
<b>unhcr_comments</b>: $unhcr_comments<br/>\
<b>ctobin111</b>: $ctobin111<br/>\
<b>me</b>: $me"
title="[FEATURE][GHG]$id $sid"
#echo "$assignee_ctobin111"
gh issue create --title "$title" --body "$body" --assignee @me$assignee_ctobin111 --label $priority,ghg --project "UNHCR - TSS"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment