From 6df5c6c59b8b1adab7e08d22d315b1bde4878afa Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Sat, 20 Aug 2022 02:57:26 +0200 Subject: [PATCH 01/11] enhancement: implemented GitHub graphql API refactor --- gh_api_lib_organization.sh | 82 +++++++++++++++++++++++++------------ gh_api_lib_user.sh | 84 +++++++++++++++++++++++++------------- 2 files changed, 111 insertions(+), 55 deletions(-) diff --git a/gh_api_lib_organization.sh b/gh_api_lib_organization.sh index 15858fb..f4991a7 100644 --- a/gh_api_lib_organization.sh +++ b/gh_api_lib_organization.sh @@ -2,39 +2,67 @@ TMP_STORE_LOCATION=/tmp/api_response.json -# getOrganizationProject queries the github api for the specific project +# getOrganizationProjectID queries the github api for the specific project uuid # 1: organization # 2: project id (number) -function getOrganizationProject() { +function getOrganizationProjectID() { local ORGANIZATION=$1 local PROJECT_NUMBER=$2 gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' query($organization: String!, $number: Int!) { - organization(login: $organization){ - projectNext(number: $number) { - id - fields(first:20) { - nodes { - id - name - settings - } - } - } + organization(login: $organization){ + projectV2(number: $number) { + id } + } }' -f organization=$ORGANIZATION -F number=$PROJECT_NUMBER > $TMP_STORE_LOCATION } -# extractOrganizationProjectID returns the project id -function extractOrganizationProjectID() { - jq '.data.organization.projectNext.id' $TMP_STORE_LOCATION | sed -e "s+\"++g" +# getOrganizationProjectFields queries the github api for the specific project fields +# 1: project id (uuid) +function getOrganizationProjectFields() { + local PROJECT_ID=$1 + gh api graphql -f query=' + query($projectId: ID!){ + node(id: $projectId) { + ... on ProjectV2 { + fields(first: 100) { + nodes { + ... on ProjectV2Field { + id + name + } + ... on ProjectV2IterationField { + id + name + configuration { + iterations { + startDate + id + title + } + } + } + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' -f projectId=$PROJECT_ID | jq .data.node.fields > $TMP_STORE_LOCATION } # extractOrganizationFieldID returns the field id # 1: field name function extractOrganizationFieldID() { local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - jq -r ".data.organization.projectNext.fields.nodes[] | select(.name == \"$fieldName\").id" $TMP_STORE_LOCATION + jq -r ".nodes[] | select(.name == \"$fieldName\").id" $TMP_STORE_LOCATION } # extractOrganizationFieldNodeIterationSettingValue returns the field node setting value id @@ -44,19 +72,19 @@ function extractOrganizationFieldID() { # NOTE: If the value is @current or @next, we check the the array of iterations and return the current or next iteration id. function extractOrganizationFieldNodeIterationSettingValue() { local field_name=$(echo $1 | sed -e "s+\"++g") # remove quotes - select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes + local select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes - iterations_for_field=$(jq ".data.organization.projectNext.fields.nodes[] | select(.name==\"$field_name\").settings | fromjson.configuration.iterations[]" $TMP_STORE_LOCATION) - dates=$(echo $iterations_for_field | jq -r ".start_date" | sort ) + iterations_for_field=$(jq ".nodes[] | select(.name==\"$field_name\").configuration.iterations" $TMP_STORE_LOCATION) + dates=$(echo $iterations_for_field | jq -r '.[] | .startDate' | sort) STRINGTEST=(${dates[@]}) if [ "$select_value" == "@current" ]; then - iteration_selected=${STRINGTEST[0]} - echo -e $iterations_for_field | jq "select(.start_date==\"$iteration_selected\") |.id" | sed -e "s+\"++g" + CURRENT_ITERATION=${STRINGTEST[0]} + echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$CURRENT_ITERATION'").id' elif [ "$select_value" == "@next" ]; then - iteration_selected=${STRINGTEST[1]} - echo -e $iterations_for_field | jq "select(.start_date==\"$iteration_selected\") |.id" | sed -e "s+\"++g" + NEXT_ITERATION=${STRINGTEST[1]} + echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$NEXT_ITERATION'").id' else - echo -e $iterations_for_field | jq "select(.title==\"$select_value\") |.id" | sed -e "s+\"++g" + echo -e $iterations_for_field | jq -r ".[] | select(.title==\"$select_value\") | .id" fi } @@ -65,6 +93,6 @@ function extractOrganizationFieldNodeIterationSettingValue() { # 2: select value function extractOrganizationFieldNodeSelectSettingValue() { local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes - jq ".data.organization.projectNext.fields.nodes[] | select(.name == \"$fieldName\").settings | fromjson.options[] | select(.name==\"$selectValue\") |.id" $TMP_STORE_LOCATION | sed -e "s+\"++g" + local selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes + jq ".nodes[] | select(.name==\"Status\").options[] | select(.name==\"Done\").id" $TMP_STORE_LOCATION | sed -e "s+\"++g" } diff --git a/gh_api_lib_user.sh b/gh_api_lib_user.sh index 4efd72d..5f066e3 100644 --- a/gh_api_lib_user.sh +++ b/gh_api_lib_user.sh @@ -2,39 +2,67 @@ TMP_STORE_LOCATION=/tmp/api_response.json -# getUserProject queries the github api for the specific project +# getUserProjectID queries the github api for the specific project uuid # 1: username # 2: project id (number) -function getUserProject() { +function getUserProjectID() { local USER=$1 local PROJECT_NUMBER=$2 - gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' + gh api graphql -f query=' query($user: String!, $number: Int!) { - user(login: $user){ - projectNext(number: $number) { + user(login: $user){ + projectV2(number: $number) { + id + } + } + }' -f user=$USER -F number=$PROJECT_NUMBER | jq .data.user.projectV2.id | sed -e 's+"++g' +} + +# getUserProjectFields queries the github api for the specific project fields +# 1: project id (uuid) +function getUserProjectFields() { + local PROJECT_ID=$1 + gh api graphql -f query=' + query($projectId: ID!){ + node(id: $projectId) { + ... on ProjectV2 { + fields(first: 100) { + nodes { + ... on ProjectV2Field { + id + name + } + ... on ProjectV2IterationField { id - fields(first:20) { - nodes { - id - name - settings - } + name + configuration { + iterations { + startDate + id + title + } } + } + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } } + } } - }' -f user=$USER -F number=$PROJECT_NUMBER > $TMP_STORE_LOCATION -} - -# extractUserProjectID returns the project id -function extractUserProjectID() { - jq '.data.user.projectNext.id' $TMP_STORE_LOCATION | sed -e "s+\"++g" + } + }' -f projectId=$PROJECT_ID | jq .data.node.fields > $TMP_STORE_LOCATION } # extractUserFieldID returns the field id # 1: field name function extractUserFieldID() { local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - jq -r ".data.user.projectNext.fields.nodes[] | select(.name == \"$fieldName\").id" $TMP_STORE_LOCATION + jq -r ".nodes[] | select(.name == \"$fieldName\").id" $TMP_STORE_LOCATION } # extractUserFieldNodeIterationSettingValue returns the field node setting value id @@ -44,19 +72,19 @@ function extractUserFieldID() { # NOTE: If the value is @current or @next, we check the the array of iterations and return the current or next iteration id. function extractUserFieldNodeIterationSettingValue() { local field_name=$(echo $1 | sed -e "s+\"++g") # remove quotes - select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes + local select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes - iterations_for_field=$(jq ".data.user.projectNext.fields.nodes[] | select(.name==\"$field_name\").settings | fromjson.configuration.iterations[]" $TMP_STORE_LOCATION) - dates=$(echo $iterations_for_field | jq -r ".start_date" | sort ) + iterations_for_field=$(jq ".nodes[] | select(.name==\"$field_name\").configuration.iterations" $TMP_STORE_LOCATION) + dates=$(echo $iterations_for_field | jq -r '.[] | .startDate' | sort) STRINGTEST=(${dates[@]}) if [ "$select_value" == "@current" ]; then - iteration_selected=${STRINGTEST[0]} - echo -e $iterations_for_field | jq "select(.start_date==\"$iteration_selected\") |.id" | sed -e "s+\"++g" + CURRENT_ITERATION=${STRINGTEST[0]} + echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$CURRENT_ITERATION'").id' elif [ "$select_value" == "@next" ]; then - iteration_selected=${STRINGTEST[1]} - echo -e $iterations_for_field | jq "select(.start_date==\"$iteration_selected\") |.id" | sed -e "s+\"++g" + NEXT_ITERATION=${STRINGTEST[1]} + echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$NEXT_ITERATION'").id' else - echo -e $iterations_for_field | jq "select(.title==\"$select_value\") |.id" | sed -e "s+\"++g" + echo -e $iterations_for_field | jq -r ".[] | select(.title==\"$select_value\") | .id" fi } @@ -65,6 +93,6 @@ function extractUserFieldNodeIterationSettingValue() { # 2: select value function extractUserFieldNodeSelectSettingValue() { local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes - jq ".data.user.projectNext.fields.nodes[] | select(.name == \"$fieldName\").settings | fromjson.options[] | select(.name==\"$selectValue\") |.id" $TMP_STORE_LOCATION | sed -e "s+\"++g" + local selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes + jq ".nodes[] | select(.name==\"Status\").options[] | select(.name==\"Done\").id" $TMP_STORE_LOCATION | sed -e "s+\"++g" } From 594bad4ee54e800eb18fa1e65e71c857697f2cdf Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Sun, 21 Aug 2022 02:02:02 +0200 Subject: [PATCH 02/11] enhancement: implemented GitHub graphql API refactor --- gh_api_global.sh | 75 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/gh_api_global.sh b/gh_api_global.sh index aed4c69..9aaefb8 100644 --- a/gh_api_global.sh +++ b/gh_api_global.sh @@ -7,14 +7,14 @@ function getItemID() { local project_id=$1 local resource_id=$2 - gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' - mutation($project:ID!, $resource_id:ID!) { - addProjectNextItem(input: {projectId: $project, contentId: $resource_id}) { - projectNextItem { + gh api graphql -f query=' + mutation($project:ID!, $pr:ID!) { + addProjectV2ItemById(input: {projectId: $project, contentId: $pr}) { + item { id } } - }' -f project=$project_id -f resource_id=$resource_id --jq '.data.addProjectNextItem.projectNextItem.id' | sed -e "s+\"++g" + }' -f project=$project_id -f pr=$resource_id --jq '.data.addProjectV2ItemById.item.id' } # updateSingleSelectField updates the given item field with the defined value @@ -28,27 +28,67 @@ function updateSingleSelectField() { local item_id=$2 local field_id=$3 local field_option=$4 - echo $(gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' + + gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' + mutation ( + $project: ID! + $item: ID! + $fieldid: ID! + $fieldOption: String! + ) { + set_status: updateProjectV2ItemFieldValue( + input: { + projectId: $project + itemId: $item + fieldId: $fieldid + value: { + singleSelectOptionId: $fieldOption + } + } + ) + { + projectV2Item { + id + } + } + }' -f project=$project_id -f item=$item_id -f fieldid=$field_id -f fieldOption=$field_option | sed -e "s+\"++g" +} + +# updateIterationField updates the given item field with the defined value +# Required arguments: +# 1: project id +# 2: project item id +# 3: field id +# 4: field option string (id as string) +function updateIterationField() { + local project_id=$1 + local item_id=$2 + local field_id=$3 + local field_option=$4 + + gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' mutation ( $project: ID! $item: ID! $fieldid: ID! $fieldOption: String! ) { - updateProjectNextItemField( + set_status: updateProjectV2ItemFieldValue( input: { projectId: $project itemId: $item fieldId: $fieldid - value: $fieldOption + value: { + iterationId: $fieldOption + } } ) { - projectNextItem { + projectV2Item { id } } - }' -f project=$project_id -f item=$item_id -f fieldid=$field_id -f fieldOption=$field_option | sed -e "s+\"++g") + }' -f project=$project_id -f item=$item_id -f fieldid=$field_id -f fieldOption=$field_option | sed -e "s+\"++g" } # updateTextField updates the given item field with the defined value @@ -62,25 +102,26 @@ function updateTextField() { local ITEM_ID=$2 local FIELD_ID=$3 local FIELD_VALUE=$4 - echo $(gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' + gh api graphql -f query=' mutation ( $project: ID! $item: ID! $fieldid: ID! $fieldValue: String! ) { - updateProjectNextItemField( + updateProjectV2ItemFieldValue( input: { projectId: $project itemId: $item fieldId: $fieldid - value: $fieldValue + value: { + text: $fieldValue + } } - ) - { - projectNextItem { + ) { + projectV2Item { id } } - }' -f project=$PROJECT_ID -f item=$ITEM_ID -f fieldid=$FIELD_ID -f fieldValue="$FIELD_VALUE" | sed -e "s+\"++g") + }' -f project=$PROJECT_ID -f item=$ITEM_ID -f fieldid=$FIELD_ID -f fieldValue="$FIELD_VALUE" | sed -e "s+\"++g" } From 03ea64719267284fb782ff0486d936c43eb965d1 Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Sun, 21 Aug 2022 02:18:49 +0200 Subject: [PATCH 03/11] test: added user tests --- test_user_2.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 test_user_2.sh diff --git a/test_user_2.sh b/test_user_2.sh new file mode 100755 index 0000000..ed9e6d2 --- /dev/null +++ b/test_user_2.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# global settings +ENTRYPOINT_MODE=user +ORG_OR_USER_NAME=leonsteinhaeuser +project_uuid=5 +RESOURCE_NODE_ID=I_kwDOGWypss4-v6dh + +source gh_api_lib_user.sh +source gh_api_global.sh +TMP_STORE_LOCATION=api_response.json + +# query project +#getUserProject "$ORG_OR_USER_NAME" "$project_uuid" +echo "project response: " + +##### project_uuid=$(getUserProjectID "$ORG_OR_USER_NAME" "$project_uuid") +echo "project_uuid: $project_uuid" +project_uuid=PVT_kwHOAoeKQc2PEQ + +##### getUserProjectFields $project_uuid + +echo "Current" +extractUserFieldNodeIterationSettingValue "Iteration" "@current" + +echo "Next" +extractUserFieldNodeIterationSettingValue "Iteration" "@next" + +echo "Select by title" +extractUserFieldNodeIterationSettingValue "Iteration" "Iteration 9" + + +# get PR or Issue global ID by resource node id +echo "Get Item ID" +issue_or_pr_item_uuid=$(getItemID "$project_uuid" "$RESOURCE_NODE_ID") +echo $issue_or_pr_item_uuid + +# single select field value update (Status) + + +echo "Status Field UUID" +status_field_uuid=$(extractUserFieldID "Status") +echo $status_field_uuid + +echo "Status done ID" +status_done_id=$(extractUserFieldNodeSelectSettingValue "Status" "Done") +echo $status_done_id + +echo "Update status" +updateSingleSelectField "$project_uuid" "$issue_or_pr_item_uuid" "$status_field_uuid" "$status_done_id" + +# single select field value update (Iteration) + +echo "Iteration Field UUID" +iteration_field_uuid=$(extractUserFieldID "Iteration") +echo $iteration_field_uuid + +echo "Iteration Current ID" +iteration_current_id=$(extractUserFieldNodeIterationSettingValue "Iteration" "@current") +echo $iteration_current_id + +updateIterationField "$project_uuid" "$issue_or_pr_item_uuid" "$iteration_field_uuid" "$iteration_current_id" + +# update text field value + +echo "Text Field UUID" +text_field_uuid=$(extractUserFieldID "Severity") +echo $text_field_uuid + +updateTextField "$project_uuid" "$issue_or_pr_item_uuid" "$text_field_uuid" "Low" \ No newline at end of file From 658e46a622c8805dafb098ade0667cf67a74269f Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Tue, 23 Aug 2022 23:02:22 +0200 Subject: [PATCH 04/11] enhancement: removed unused lines of code --- gh_api_lib_user.sh | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/gh_api_lib_user.sh b/gh_api_lib_user.sh index 5f066e3..5219b73 100644 --- a/gh_api_lib_user.sh +++ b/gh_api_lib_user.sh @@ -1,7 +1,5 @@ #!/bin/bash -TMP_STORE_LOCATION=/tmp/api_response.json - # getUserProjectID queries the github api for the specific project uuid # 1: username # 2: project id (number) @@ -58,41 +56,3 @@ function getUserProjectFields() { }' -f projectId=$PROJECT_ID | jq .data.node.fields > $TMP_STORE_LOCATION } -# extractUserFieldID returns the field id -# 1: field name -function extractUserFieldID() { - local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - jq -r ".nodes[] | select(.name == \"$fieldName\").id" $TMP_STORE_LOCATION -} - -# extractUserFieldNodeIterationSettingValue returns the field node setting value id -# 1: field name -# 2: select value -# -# NOTE: If the value is @current or @next, we check the the array of iterations and return the current or next iteration id. -function extractUserFieldNodeIterationSettingValue() { - local field_name=$(echo $1 | sed -e "s+\"++g") # remove quotes - local select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes - - iterations_for_field=$(jq ".nodes[] | select(.name==\"$field_name\").configuration.iterations" $TMP_STORE_LOCATION) - dates=$(echo $iterations_for_field | jq -r '.[] | .startDate' | sort) - STRINGTEST=(${dates[@]}) - if [ "$select_value" == "@current" ]; then - CURRENT_ITERATION=${STRINGTEST[0]} - echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$CURRENT_ITERATION'").id' - elif [ "$select_value" == "@next" ]; then - NEXT_ITERATION=${STRINGTEST[1]} - echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$NEXT_ITERATION'").id' - else - echo -e $iterations_for_field | jq -r ".[] | select(.title==\"$select_value\") | .id" - fi -} - -# extractUserFieldNodeSelectSettingValue returns the field node setting value id -# 1: field name -# 2: select value -function extractUserFieldNodeSelectSettingValue() { - local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - local selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes - jq ".nodes[] | select(.name==\"Status\").options[] | select(.name==\"Done\").id" $TMP_STORE_LOCATION | sed -e "s+\"++g" -} From fca22766e5d0765d6c5b296fb8ae9212762af385 Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Tue, 23 Aug 2022 23:04:23 +0200 Subject: [PATCH 05/11] enhancement: improved github api field value handling --- gh_api_global.sh | 112 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/gh_api_global.sh b/gh_api_global.sh index 9aaefb8..3fb7e55 100644 --- a/gh_api_global.sh +++ b/gh_api_global.sh @@ -17,6 +17,45 @@ function getItemID() { }' -f project=$project_id -f pr=$resource_id --jq '.data.addProjectV2ItemById.item.id' } +# extractFieldID returns the field uuid +# 1: field name (string) +function extractFieldID() { + local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes + jq -r ".nodes[] | select(.name == \"$fieldName\").id" $TMP_STORE_LOCATION +} + +# extractFieldNodeSingleSelectSettingValue returns the field node setting value id +# 1: field name (string) +# 2: select value (string) +function extractFieldNodeSingleSelectSettingValue() { + local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes + local selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes + jq ".nodes[] | select(.name==\"$fieldName\").options[] | select(.name==\"$selectValue\").id" $TMP_STORE_LOCATION | sed -e "s+\"++g" +} + +# extractFieldNodeIterationSettingValue returns the field node setting value id +# 1: field name (string) +# 2: select value (string) +# +# NOTE: If the value is @current or @next, we check the the array of iterations and return the current or next iteration id. +function extractFieldNodeIterationSettingValue() { + local field_name=$(echo $1 | sed -e "s+\"++g") # remove quotes + local select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes + + iterations_for_field=$(jq ".nodes[] | select(.name==\"$field_name\").configuration.iterations" $TMP_STORE_LOCATION) + dates=$(echo $iterations_for_field | jq -r '.[] | .startDate' | sort) + STRINGTEST=(${dates[@]}) + if [ "$select_value" == "@current" ]; then + CURRENT_ITERATION=${STRINGTEST[0]} + echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$CURRENT_ITERATION'").id' + elif [ "$select_value" == "@next" ]; then + NEXT_ITERATION=${STRINGTEST[1]} + echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$NEXT_ITERATION'").id' + else + echo -e $iterations_for_field | jq -r ".[] | select(.title==\"$select_value\") | .id" + fi +} + # updateSingleSelectField updates the given item field with the defined value # Required arguments: # 1: project id @@ -29,14 +68,14 @@ function updateSingleSelectField() { local field_id=$3 local field_option=$4 - gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' + gh api graphql -f query=' mutation ( $project: ID! $item: ID! $fieldid: ID! $fieldOption: String! ) { - set_status: updateProjectV2ItemFieldValue( + updateProjectV2ItemFieldValue( input: { projectId: $project itemId: $item @@ -125,3 +164,72 @@ function updateTextField() { } }' -f project=$PROJECT_ID -f item=$ITEM_ID -f fieldid=$FIELD_ID -f fieldValue="$FIELD_VALUE" | sed -e "s+\"++g" } + +# updateNumberField updates the given item field with the defined value +# Required arguments: +# 1: project id +# 2: project item id +# 3: field id +# 4: field value +function updateNumberField() { + local PROJECT_ID=$1 + local ITEM_ID=$2 + local FIELD_ID=$3 + local FIELD_VALUE=$4 + gh api graphql -f query=" + mutation ( + \$project: ID! + \$item: ID! + \$fieldid: ID! + ) { + updateProjectV2ItemFieldValue( + input: { + projectId: \$project + itemId: \$item + fieldId: \$fieldid + value: { + number: $FIELD_VALUE + } + } + ) { + projectV2Item { + id + } + } + }" -f project=$PROJECT_ID -f item=$ITEM_ID -f fieldid=$FIELD_ID | sed -e "s+\"++g" +} + +# updateDateField updates the given item field with the defined value +# Required arguments: +# 1: project id +# 2: project item id +# 3: field id +# 4: field value +function updateDateField() { + local PROJECT_ID=$1 + local ITEM_ID=$2 + local FIELD_ID=$3 + local FIELD_VALUE=$4 + gh api graphql -f query=' + mutation ( + $project: ID! + $item: ID! + $fieldid: ID! + $fieldValue: Date! + ) { + updateProjectV2ItemFieldValue( + input: { + projectId: $project + itemId: $item + fieldId: $fieldid + value: { + date: $fieldValue + } + } + ) { + projectV2Item { + id + } + } + }' -f project=$PROJECT_ID -f item=$ITEM_ID -f fieldid=$FIELD_ID -f fieldValue="$FIELD_VALUE" | sed -e "s+\"++g" +} \ No newline at end of file From 7911783ac3d4898d44616c92231bfaf82f005f5b Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Tue, 23 Aug 2022 23:04:58 +0200 Subject: [PATCH 06/11] docs: added note about the v2 changes --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2029c83..7615b75 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ For more information, see [Creating a personal access token](https://docs.github > > https://github.blog/changelog/2022-02-23-the-new-github-issues-february-23rd-update/ +## V1 vs V2 + +In June 2022, [GitHub announced a breaking change to the Projects API](https://github.blog/changelog/2022-06-23-the-new-github-issues-june-23rd-update/). Therefore, the @v1 tag of this action will stop working on October 1, 2022. You can switch to the @v2 tag at any time (by updating the reference in your workflow file). + ## Project board Since the issues and pull requests from this repository are also managed by this automation, you can take an example from the public project board to see what it looks like. From 54b97a08b8ed36090d0dca6b7cdb3b29a0e6d248 Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Sun, 28 Aug 2022 22:47:54 +0200 Subject: [PATCH 07/11] enhancement: improved organization lib --- gh_api_lib_organization.sh | 49 ++++---------------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/gh_api_lib_organization.sh b/gh_api_lib_organization.sh index f4991a7..c20b41d 100644 --- a/gh_api_lib_organization.sh +++ b/gh_api_lib_organization.sh @@ -1,21 +1,19 @@ #!/bin/bash -TMP_STORE_LOCATION=/tmp/api_response.json - # getOrganizationProjectID queries the github api for the specific project uuid -# 1: organization +# 1: organization (string) # 2: project id (number) function getOrganizationProjectID() { local ORGANIZATION=$1 local PROJECT_NUMBER=$2 gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' - query($organization: String!, $number: Int!) { - organization(login: $organization){ + query($org: String!, $number: Int!) { + organization(login: $org){ projectV2(number: $number) { id } } - }' -f organization=$ORGANIZATION -F number=$PROJECT_NUMBER > $TMP_STORE_LOCATION + }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER | jq .data.organization.projectV2.id | sed -e 's+"++g' } # getOrganizationProjectFields queries the github api for the specific project fields @@ -57,42 +55,3 @@ function getOrganizationProjectFields() { } }' -f projectId=$PROJECT_ID | jq .data.node.fields > $TMP_STORE_LOCATION } - -# extractOrganizationFieldID returns the field id -# 1: field name -function extractOrganizationFieldID() { - local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - jq -r ".nodes[] | select(.name == \"$fieldName\").id" $TMP_STORE_LOCATION -} - -# extractOrganizationFieldNodeIterationSettingValue returns the field node setting value id -# 1: field name -# 2: select value -# -# NOTE: If the value is @current or @next, we check the the array of iterations and return the current or next iteration id. -function extractOrganizationFieldNodeIterationSettingValue() { - local field_name=$(echo $1 | sed -e "s+\"++g") # remove quotes - local select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes - - iterations_for_field=$(jq ".nodes[] | select(.name==\"$field_name\").configuration.iterations" $TMP_STORE_LOCATION) - dates=$(echo $iterations_for_field | jq -r '.[] | .startDate' | sort) - STRINGTEST=(${dates[@]}) - if [ "$select_value" == "@current" ]; then - CURRENT_ITERATION=${STRINGTEST[0]} - echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$CURRENT_ITERATION'").id' - elif [ "$select_value" == "@next" ]; then - NEXT_ITERATION=${STRINGTEST[1]} - echo -e $iterations_for_field | jq -r '.[] | select(.startDate == "'$NEXT_ITERATION'").id' - else - echo -e $iterations_for_field | jq -r ".[] | select(.title==\"$select_value\") | .id" - fi -} - -# extractOrganizationFieldNodeSelectSettingValue returns the field node setting value id -# 1: field name -# 2: select value -function extractOrganizationFieldNodeSelectSettingValue() { - local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - local selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes - jq ".nodes[] | select(.name==\"Status\").options[] | select(.name==\"Done\").id" $TMP_STORE_LOCATION | sed -e "s+\"++g" -} From 1b8d4d5a767f53c4c6c6e6d799665da76cb1c469 Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Sun, 28 Aug 2022 23:08:55 +0200 Subject: [PATCH 08/11] tests: improved user tests --- test_user.sh | 50 ++++++++++++++++++++++++------------ test_user_2.sh | 70 -------------------------------------------------- 2 files changed, 33 insertions(+), 87 deletions(-) delete mode 100755 test_user_2.sh diff --git a/test_user.sh b/test_user.sh index fa0d3d1..8a4f11d 100755 --- a/test_user.sh +++ b/test_user.sh @@ -1,5 +1,8 @@ #!/bin/bash +export DEBUG_COMMANDS="false" +export DEBUG_LOG="true" + # global settings ENTRYPOINT_MODE=user ORG_OR_USER_NAME=leonsteinhaeuser @@ -9,28 +12,45 @@ RESOURCE_NODE_ID=I_kwDOGWypss4-v6dh ENTRYPOINT_SCRIPT=./entrypoint.sh # change the status of a pr or issue -ENTRYPOINT_TYPE=status -RESOURCE_NODE_VALUE=Done -$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" +#ENTRYPOINT_TYPE=status +#RESOURCE_NODE_VALUE=Done +#$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" # change the status of a pr or issue to '' -$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" +#echo "===== change status" +#$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" # change the value of custom fields -date=$(date -d "+10 days" --rfc-3339=ns | sed 's/ /T/; s/\(\....\).*\([+-]\)/\1\2/g') +date=$(date +"%Y-%m-%d") uuid1=$(uuidgen) uuid2=$(uuidgen) -random_number=$(( $RANDOM % 2500 )) +random_number=$(( $RANDOM % 10 )).$(( $RANDOM % 10 )) + custom_fields="[ + { + \"name\": \"Single Select\", + \"type\": \"single_select\", + \"value\": \"Option 2\" + }, { \"name\": \"Priority\", \"type\": \"text\", \"value\": \"$uuid1\" }, { - \"name\": \"Number\", - \"type\": \"number\", - \"value\": \"$random_number\" + \"name\": \"Iteration\", + \"type\": \"iteration\", + \"value\": \"Iteration 10\" + }, + { + \"name\": \"Iteration\", + \"type\": \"iteration\", + \"value\": \"@current\" + }, + { + \"name\": \"Iteration\", + \"type\": \"iteration\", + \"value\": \"@next\" }, { \"name\": \"Date\", @@ -38,17 +58,13 @@ custom_fields="[ \"value\": \"$date\" }, { - \"name\": \"Single Select\", - \"type\": \"single_select\", - \"value\": \"Option 1\" - }, - { - \"name\": \"Iteration\", - \"type\": \"iteration\", - \"value\": \"Iteration 3\" + \"name\": \"Number\", + \"type\": \"number\", + \"value\": \"$random_number\" } ]" +echo "===== change custom fields" ENTRYPOINT_TYPE=custom_field RESOURCE_NODE_VALUE=$custom_fields $ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" diff --git a/test_user_2.sh b/test_user_2.sh deleted file mode 100755 index ed9e6d2..0000000 --- a/test_user_2.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -# global settings -ENTRYPOINT_MODE=user -ORG_OR_USER_NAME=leonsteinhaeuser -project_uuid=5 -RESOURCE_NODE_ID=I_kwDOGWypss4-v6dh - -source gh_api_lib_user.sh -source gh_api_global.sh -TMP_STORE_LOCATION=api_response.json - -# query project -#getUserProject "$ORG_OR_USER_NAME" "$project_uuid" -echo "project response: " - -##### project_uuid=$(getUserProjectID "$ORG_OR_USER_NAME" "$project_uuid") -echo "project_uuid: $project_uuid" -project_uuid=PVT_kwHOAoeKQc2PEQ - -##### getUserProjectFields $project_uuid - -echo "Current" -extractUserFieldNodeIterationSettingValue "Iteration" "@current" - -echo "Next" -extractUserFieldNodeIterationSettingValue "Iteration" "@next" - -echo "Select by title" -extractUserFieldNodeIterationSettingValue "Iteration" "Iteration 9" - - -# get PR or Issue global ID by resource node id -echo "Get Item ID" -issue_or_pr_item_uuid=$(getItemID "$project_uuid" "$RESOURCE_NODE_ID") -echo $issue_or_pr_item_uuid - -# single select field value update (Status) - - -echo "Status Field UUID" -status_field_uuid=$(extractUserFieldID "Status") -echo $status_field_uuid - -echo "Status done ID" -status_done_id=$(extractUserFieldNodeSelectSettingValue "Status" "Done") -echo $status_done_id - -echo "Update status" -updateSingleSelectField "$project_uuid" "$issue_or_pr_item_uuid" "$status_field_uuid" "$status_done_id" - -# single select field value update (Iteration) - -echo "Iteration Field UUID" -iteration_field_uuid=$(extractUserFieldID "Iteration") -echo $iteration_field_uuid - -echo "Iteration Current ID" -iteration_current_id=$(extractUserFieldNodeIterationSettingValue "Iteration" "@current") -echo $iteration_current_id - -updateIterationField "$project_uuid" "$issue_or_pr_item_uuid" "$iteration_field_uuid" "$iteration_current_id" - -# update text field value - -echo "Text Field UUID" -text_field_uuid=$(extractUserFieldID "Severity") -echo $text_field_uuid - -updateTextField "$project_uuid" "$issue_or_pr_item_uuid" "$text_field_uuid" "Low" \ No newline at end of file From 5560891c006024bad07b608aa31b846e25df227d Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Sun, 28 Aug 2022 23:46:22 +0200 Subject: [PATCH 09/11] enhancement: improved organization and user field handling --- entrypoint.sh | 107 ++++++++++---------------------------------------- 1 file changed, 21 insertions(+), 86 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 608cf86..80acebe 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -72,6 +72,8 @@ fi ####################################################################################################### ####################################################################################################### +export TMP_STORE_LOCATION="/tmp/api_${ENTRYPOINT_MODE}_response.json" + # load the api libs source gh_api_lib_user.sh source gh_api_lib_organization.sh @@ -84,78 +86,12 @@ PROJECT_ITEM_UUID="" # stores the log output the script produces log="" -function updateOrganizationScope() { - case "$ENTRYPOINT_TYPE" in - status) - STATUS_FIELD_ID=$(extractOrganizationFieldID "Status") - STATUS_FIELD_VALUE_ID=$(extractOrganizationFieldNodeSelectSettingValue "Status" "$RESOURCE_NODE_VALUE") - response=$(updateSingleSelectField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" "$STATUS_FIELD_ID" "$STATUS_FIELD_VALUE_ID") - log="$log\n$response" - ;; - custom_field) - x=0 # counter - while true; do - nameField=$(echo $RESOURCE_NODE_VALUE | jq ".[$x].name" | sed 's/\"//g') - typeField=$(echo $RESOURCE_NODE_VALUE | jq ".[$x].type" | sed 's/\"//g') - valueField=$(echo $RESOURCE_NODE_VALUE | jq ".[$x].value") - if [ "$nameField" == "null" ] || [ "$valueField" == "null" ]; then - # no more custom fields - break - else - local fieldID=$(extractOrganizationFieldID "$nameField") - log="$log\n\n$nameField: $fieldID" - case $typeField in - 'text') - log="$log\nUpdating text field: $nameField with value: $valueField" - response=$(updateTextField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" $fieldID "$valueField") - log="$log\n$response\n" - ;; - "number") - valueFieldWithoutQuotes=$(echo $valueField | sed 's/\"//g') - log="$log\nUpdating number field: $nameField with value: $valueFieldWithoutQuotes" - response=$(updateTextField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" $fieldID "$valueFieldWithoutQuotes") - log="$log\n$response\n" - ;; - "date") - log="$log\nUpdating date field: $nameField with value: $valueField" - response=$(updateTextField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" $fieldID "$valueField") - log="$log\n$response\n" - ;; - "single_select") - log="$log\nUpdating single select field: $nameField with value: $valueField" - selectedOption=$(extractOrganizationFieldNodeSelectSettingValue "$nameField" "$valueField") - log="$log\nSingle Select Option: $selectedOption" - response=$(updateSingleSelectField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" "$fieldID" "$selectedOption") - log="$log\n$response\n" - ;; - "iteration") - log="$log\nUpdating iteration field: $nameField with value: $valueField" - iterationFieldNodeID=$(extractOrganizationFieldNodeIterationSettingValue "$nameField" "$valueField") - log="$log\nIteration Node ID: $iterationFieldNodeID" - response=$(updateSingleSelectField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" "$fieldID" "$iterationFieldNodeID") - log="$log\n$response\n" - ;; - *) - echo "Unknown field type: $typeField" - exit -1 - ;; - esac - fi - x=$(( $x + 1 )) - done - ;; - *) - echo "Unknown ENTRYPOINT_TYPE: $ENTRYPOINT_TYPE" - exit 2 - ;; - esac -} -function updateUserScope() { +function updateFieldScope() { case "$ENTRYPOINT_TYPE" in status) - STATUS_FIELD_ID=$(extractUserFieldID "Status") - STATUS_FIELD_VALUE_ID=$(extractUserFieldNodeSelectSettingValue "Status" "$RESOURCE_NODE_VALUE") + STATUS_FIELD_ID=$(extractFieldID "Status") + STATUS_FIELD_VALUE_ID=$(extractFieldNodeSingleSelectSettingValue "Status" "$RESOURCE_NODE_VALUE") response=$(updateSingleSelectField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" "$STATUS_FIELD_ID" "$STATUS_FIELD_VALUE_ID") log="$log\n$response" ;; @@ -169,7 +105,7 @@ function updateUserScope() { # no more custom fields break else - local fieldID=$(extractUserFieldID "$nameField") + local fieldID=$(extractFieldID "$nameField") log="$log\n\n$nameField: $fieldID" case $typeField in 'text') @@ -180,26 +116,25 @@ function updateUserScope() { "number") valueFieldWithoutQuotes=$(echo $valueField | sed 's/\"//g') log="$log\nUpdating number field: $nameField with value: $valueFieldWithoutQuotes" - response=$(updateTextField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" $fieldID "$valueFieldWithoutQuotes") + response=$(updateNumberField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" $fieldID "$valueFieldWithoutQuotes") log="$log\n$response\n" ;; "date") - log="$log\nUpdating date field: $nameField with value: $valueField" - response=$(updateTextField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" $fieldID "$valueField") + valueFieldWithoutQuotes=$(echo $valueField | sed 's/\"//g') + log="$log\nUpdating date field: $nameField with value: $valueFieldWithoutQuotes" + response=$(updateDateField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" $fieldID "$valueFieldWithoutQuotes") log="$log\n$response\n" ;; "single_select") log="$log\nUpdating single select field: $nameField with value: $valueField" - selectedOption=$(extractUserFieldNodeSelectSettingValue "$nameField" "$valueField") - log="$log\nSingle Select Option: $selectedOption" + selectedOption=$(extractFieldNodeSingleSelectSettingValue "$nameField" "$valueField") response=$(updateSingleSelectField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" "$fieldID" "$selectedOption") log="$log\n$response\n" ;; "iteration") log="$log\nUpdating iteration field: $nameField with value: $valueField" - iterationFieldNodeID=$(extractUserFieldNodeIterationSettingValue "$nameField" "$valueField") - log="$log\nIteration Node ID: $iterationFieldNodeID" - response=$(updateSingleSelectField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" "$fieldID" "$iterationFieldNodeID") + iterationFieldNodeID=$(extractFieldNodeIterationSettingValue "$nameField" "$valueField") + response=$(updateIterationField "$PROJECT_UUID" "$PROJECT_ITEM_UUID" "$fieldID" "$iterationFieldNodeID") log="$log\n$response\n" ;; *) @@ -221,20 +156,20 @@ function updateUserScope() { # main entrypoint for the application case "$ENTRYPOINT_MODE" in organization) - getOrganizationProject "$ORG_OR_USER_NAME" "$PROJECT_ID" - # extract project uuid and assign it to the variable PROJECT_UUID - PROJECT_UUID=$(extractOrganizationProjectID) + PROJECT_UUID=$(getOrganizationProjectID "$ORG_OR_USER_NAME" "$PROJECT_ID") + echo "PROJECT_UUID: $PROJECT_UUID" + getOrganizationProjectFields "$PROJECT_UUID" PROJECT_ITEM_UUID=$(getItemID $PROJECT_UUID $RESOURCE_NODE_ID) - updateOrganizationScope + updateFieldScope ;; user) - getUserProject "$ORG_OR_USER_NAME" "$PROJECT_ID" - # extract project uuid and assign it to the variable PROJECT_UUID - PROJECT_UUID=$(extractUserProjectID) + PROJECT_UUID=$(getUserProjectID "$ORG_OR_USER_NAME" "$PROJECT_ID") + echo "PROJECT_UUID: $PROJECT_UUID" + getUserProjectFields "$PROJECT_UUID" PROJECT_ITEM_UUID=$(getItemID $PROJECT_UUID $RESOURCE_NODE_ID) - updateUserScope + updateFieldScope ;; *) echo "ENTRYPOINT_MODE $ENTRYPOINT_MODE is not supported" From 1b8fc8613f9c2f6eb19ea341ae88e5a45788d063 Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Sun, 28 Aug 2022 23:46:56 +0200 Subject: [PATCH 10/11] tests: improved organization test cases --- test_organization.sh | 52 +++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/test_organization.sh b/test_organization.sh index ed8d4b8..e6ff9a0 100755 --- a/test_organization.sh +++ b/test_organization.sh @@ -1,5 +1,8 @@ #!/bin/bash +export DEBUG_COMMANDS="false" +export DEBUG_LOG="true" + # global settings ENTRYPOINT_MODE=organization ORG_OR_USER_NAME=computingoverload @@ -9,29 +12,45 @@ RESOURCE_NODE_ID=I_kwDOGoqhi85BTjcx ENTRYPOINT_SCRIPT=./entrypoint.sh # change the status of a pr or issue -ENTRYPOINT_TYPE=status -RESOURCE_NODE_VALUE=Done -$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" +#ENTRYPOINT_TYPE=status +#RESOURCE_NODE_VALUE=Done +#$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" + +# change the status of a pr or issue to '' +#echo "===== change status" +#$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" # change the value of custom fields -date=$(date -d "+10 days" --rfc-3339=ns | sed 's/ /T/; s/\(\....\).*\([+-]\)/\1\2/g') +date=$(date +"%Y-%m-%d") uuid1=$(uuidgen) uuid2=$(uuidgen) +random_number=$(( $RANDOM % 10 )).$(( $RANDOM % 10 )) + custom_fields="[ + { + \"name\": \"Single Select\", + \"type\": \"single_select\", + \"value\": \"Option 2\" + }, { \"name\": \"Priority\", \"type\": \"text\", \"value\": \"$uuid1\" }, { - \"name\": \"Severity\", - \"type\": \"text\", - \"value\": \"$uuid2\" + \"name\": \"Iteration\", + \"type\": \"iteration\", + \"value\": \"Iteration 12\" }, { - \"name\": \"Number\", - \"type\": \"number\", - \"value\": \"1000000\", + \"name\": \"Iteration\", + \"type\": \"iteration\", + \"value\": \"@current\" + }, + { + \"name\": \"Iteration\", + \"type\": \"iteration\", + \"value\": \"@next\" }, { \"name\": \"Date\", @@ -39,21 +58,18 @@ custom_fields="[ \"value\": \"$date\" }, { - \"name\": \"Single Select\", - \"type\": \"single_select\", - \"value\": \"Option 1\" - }, - { - \"name\": \"Iteration\", - \"type\": \"iteration\", - \"value\": \"Iteration 1\" + \"name\": \"Number\", + \"type\": \"number\", + \"value\": \"$random_number\" } ]" +echo "===== change custom fields" ENTRYPOINT_TYPE=custom_field RESOURCE_NODE_VALUE=$custom_fields $ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" + custom_fields="[ { \"name\": \"Iteration\", From 1fee3df20980847263f4db938d178aa793ba979e Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Sun, 28 Aug 2022 23:48:52 +0200 Subject: [PATCH 11/11] tests: enabled status assign test --- test_organization.sh | 6 +++--- test_user.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test_organization.sh b/test_organization.sh index e6ff9a0..a3572bf 100755 --- a/test_organization.sh +++ b/test_organization.sh @@ -12,9 +12,9 @@ RESOURCE_NODE_ID=I_kwDOGoqhi85BTjcx ENTRYPOINT_SCRIPT=./entrypoint.sh # change the status of a pr or issue -#ENTRYPOINT_TYPE=status -#RESOURCE_NODE_VALUE=Done -#$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" +ENTRYPOINT_TYPE=status +RESOURCE_NODE_VALUE=Done +$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" # change the status of a pr or issue to '' #echo "===== change status" diff --git a/test_user.sh b/test_user.sh index 8a4f11d..e534e94 100755 --- a/test_user.sh +++ b/test_user.sh @@ -12,9 +12,9 @@ RESOURCE_NODE_ID=I_kwDOGWypss4-v6dh ENTRYPOINT_SCRIPT=./entrypoint.sh # change the status of a pr or issue -#ENTRYPOINT_TYPE=status -#RESOURCE_NODE_VALUE=Done -#$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" +ENTRYPOINT_TYPE=status +RESOURCE_NODE_VALUE=Done +$ENTRYPOINT_SCRIPT "$ENTRYPOINT_MODE" "$ENTRYPOINT_TYPE" "$ORG_OR_USER_NAME" "$PROJECT_ID" "$RESOURCE_NODE_ID" "$RESOURCE_NODE_VALUE" # change the status of a pr or issue to '' #echo "===== change status"