@@ -26,44 +26,45 @@ jobs:
26
26
status_field_id="PVTF_lADOAQFeYs4AAsTrzgAXRuU" # Status
27
27
triage_option_id="2a08fafa"
28
28
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
51
36
}
52
37
}
53
- }
54
- }' -f item_id="$issue_id"
38
+ }' -f project_id="$project_id" -f content_id="$issue_id" -q '.data.addProjectV2ItemById.item.id'
55
39
)"
56
40
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"
59
42
60
- if [ -z "$current_status " ] ; then
43
+ if [ -z "$item_id " ] ; then
61
44
echo "Issue not found in Gardener board"
62
45
exit 0
63
46
else
64
- echo "Found issue on Gardener board. Current issue status is: '${current_status}' "
47
+ echo "Found issue on Gardener board"
65
48
fi
66
49
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
+
67
68
if [ "$current_status" = "Blocked / Waiting" ] ; then
68
69
echo "Moving issue from 'Blocked / Waiting' to 'Triage'"
69
70
gh api graphql -f query='
0 commit comments