@@ -26,44 +26,45 @@ jobs:
2626 status_field_id="PVTF_lADOAQFeYs4AAsTrzgAXRuU" # Status
2727 triage_option_id="2a08fafa"
2828
29- # Query for project items for the given issue
30- project_items="$(gh api graphql -f query='
31- query($item_id: ID!) {
32- node(id: $item_id) {
33- ... on Issue {
34- projectItems(first: 50) {
35- ... on ProjectV2ItemConnection {
36- nodes {
37- fieldValueByName(name: "Status") {
38- ... on ProjectV2ItemFieldSingleSelectValue {
39- name
40- }
41- }
42- ... on ProjectV2Item {
43- project {
44- ... on ProjectV2 {
45- id
46- }
47- }
48- }
49- }
50- }
29+ # ensures that the issue is already on board but also seems to be the only way to fetch
30+ # the item id
31+ item_id="$(gh api graphql -f query='
32+ mutation($project_id: ID!, $content_id: ID!) {
33+ addProjectV2ItemById(input: {projectId: $project_id, contentId: $content_id}) {
34+ item {
35+ id
5136 }
5237 }
53- }
54- }' -f item_id="$issue_id"
38+ }' -f project_id="$project_id" -f content_id="$issue_id" -q '.data.addProjectV2ItemById.item.id'
5539 )"
5640
57- # Extract the item in the Gardener project
58- current_status=$(echo $project_items | jq -r '.data.node.projectItems.nodes[] | select(.project.id == $project_id) | .fieldValueByName.name')
41+ echo "item_id: $item_id"
5942
60- if [ -z "$current_status " ] ; then
43+ if [ -z "$item_id " ] ; then
6144 echo "Issue not found in Gardener board"
6245 exit 0
6346 else
64- echo "Found issue on Gardener board. Current issue status is: '${current_status}' "
47+ echo "Found issue on Gardener board"
6548 fi
6649
50+ current_status="$(gh api graphql -f query='
51+ query($item_id: ID!) {
52+ node(id: $item_id) {
53+ ... on ProjectV2Item {
54+ fieldValueByName(name: "Status") {
55+ ... on ProjectV2ItemFieldSingleSelectValue {
56+ name
57+ }
58+ }
59+ }
60+ }
61+ }' -f item_id="$item_id"
62+ )"
63+
64+ current_status=$(echo $current_status | jq -c -r '.["data"]["node"]["fieldValueByName"]["name"]')
65+
66+ echo "Current issue status is: '${current_status}'"
67+
6768 if [ "$current_status" = "Blocked / Waiting" ] ; then
6869 echo "Moving issue from 'Blocked / Waiting' to 'Triage'"
6970 gh api graphql -f query='
0 commit comments