@@ -26,44 +26,43 @@ jobs:
26
26
status_field_id="PVTF_lADOAQFeYs4AAsTrzgAXRuU" # Status
27
27
triage_option_id="2a08fafa"
28
28
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
36
- }
37
- }
38
- }' -f project_id="$project_id" -f content_id="$issue_id" -q '.data.addProjectV2ItemById.item.id'
39
- )"
40
-
41
- echo "item_id: $item_id"
42
-
43
- if [ -z "$item_id" ] ; then
44
- echo "Issue not found in Gardener board"
45
- exit 0
46
- else
47
- echo "Found issue on Gardener board"
48
- fi
49
-
50
- current_status="$(gh api graphql -f query='
29
+ # Query for project items for the given issue
30
+ project_items="$(gh api graphql -f query='
51
31
query($item_id: ID!) {
52
32
node(id: $item_id) {
53
- ... on ProjectV2Item {
54
- fieldValueByName(name: "Status") {
55
- ... on ProjectV2ItemFieldSingleSelectValue {
56
- name
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
+ }
57
50
}
58
51
}
59
52
}
60
53
}
61
- }' -f item_id="$item_id "
54
+ }' -f item_id="$issue_id "
62
55
)"
63
56
64
- current_status=$(echo $current_status | jq -c -r '.["data"]["node"]["fieldValueByName"]["name"]')
57
+ # Extract the item in the Gardener project
58
+ current_status=$(echo $project_items | jq -c -r --arg project_id $project_id '.data.node.projectItems.nodes[] | select(.project.id == $project_id) | .fieldValueByName.name')
65
59
66
- echo "Current issue status is: '${current_status}'"
60
+ if [ -z "$current_status" ] ; then
61
+ echo "Issue not found in Gardener board"
62
+ exit 0
63
+ else
64
+ echo "Found issue on Gardener board. Current issue status is: '${current_status}'"
65
+ fi
67
66
68
67
if [ "$current_status" = "Blocked / Waiting" ] ; then
69
68
echo "Moving issue from 'Blocked / Waiting' to 'Triage'"
0 commit comments