@@ -518,45 +518,46 @@ create_test_discussion() {
518518 local body=" $2 "
519519 local category=" ${3:- General} "
520520
521- # Get repository ID and category ID using GraphQL
522- local repo_id=$( gh api graphql -f query='
523- {
524- repository(owner: "' $REPO_OWNER ' ", name: "' $REPO_NAME ' ") {
521+ # Get repository ID using GraphQL
522+ local repo_query=" {
523+ repository(owner: \" $REPO_OWNER \" , name: \" $REPO_NAME \" ) {
525524 id
526525 }
527- }' --jq ' .data.repository.id' 2> /dev/null)
526+ }"
527+ local repo_id=$( gh api graphql -f query=" $repo_query " --jq ' .data.repository.id' 2> /dev/null)
528528
529- local category_id= $( gh api graphql -f query= '
530- {
531- repository(owner: " ' $REPO_OWNER ' ", name: " ' $REPO_NAME ' ") {
529+ # Get category ID using GraphQL
530+ local category_query= " {
531+ repository(owner: \" $REPO_OWNER \ " , name: \" $REPO_NAME \ " ) {
532532 discussionCategories(first: 10) {
533533 nodes {
534534 id
535535 name
536536 }
537537 }
538538 }
539- }' --jq ' .data.repository.discussionCategories.nodes[] | select(.name=="' $category ' ") | .id' 2> /dev/null)
539+ }"
540+ local category_id=$( gh api graphql -f query=" $category_query " --jq " .data.repository.discussionCategories.nodes[] | select(.name==\" $category \" ) | .id" 2> /dev/null)
540541
541542 if [[ -z " $repo_id " || -z " $category_id " ]]; then
542543 echo " "
543544 return
544545 fi
545546
546547 # Create discussion using GraphQL mutation
547- local discussion_data=$( gh api graphql -f query='
548- mutation {
548+ local mutation=" mutation {
549549 createDiscussion(input: {
550- repositoryId: " ' $repo_id ' "
551- categoryId: " ' $category_id ' "
552- title: " ' $title ' "
553- body: " ' $body ' "
550+ repositoryId: \" $repo_id \ "
551+ categoryId: \" $category_id \ "
552+ title: \" $title \ "
553+ body: \" $body \ "
554554 }) {
555555 discussion {
556556 number
557557 }
558558 }
559- }' --jq ' .data.createDiscussion.discussion.number // empty' 2> /dev/null)
559+ }"
560+ local discussion_data=$( gh api graphql -f query=" $mutation " --jq ' .data.createDiscussion.discussion.number // empty' 2> /dev/null)
560561
561562 if [[ -n " $discussion_data " ]]; then
562563 echo " $discussion_data "
0 commit comments