Skip to content

Commit 47c3da1

Browse files
dsmith3197jszwedko
andauthored
chore(ci): fix gardener issues comment workflow (#17825)
As it was previously implemented, this workflow would add an issue to the Gardener board if it wasn't already present. This updates the graphql query to fetch the necessary project item id without creating new items. Tested the graphql query in the [playground](https://docs.github.com/en/graphql/overview/explorer). Tested the `jq` command locally. Example Issue ID: `I_kwDOCLjIc85p9V5j` --------- Co-authored-by: Jesse Szwedko <[email protected]>
1 parent fe730ad commit 47c3da1

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

.github/workflows/gardener_issue_comment.yml

+28-29
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,43 @@ jobs:
2626
status_field_id="PVTF_lADOAQFeYs4AAsTrzgAXRuU" # Status
2727
triage_option_id="2a08fafa"
2828
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='
5131
query($item_id: ID!) {
5232
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+
}
5750
}
5851
}
5952
}
6053
}
61-
}' -f item_id="$item_id"
54+
}' -f item_id="$issue_id"
6255
)"
6356
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 -r '.data.node.projectItems.nodes[] | select(.project.id == $project_id) | .fieldValueByName.name')
6559
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
6766
6867
if [ "$current_status" = "Blocked / Waiting" ] ; then
6968
echo "Moving issue from 'Blocked / Waiting' to 'Triage'"

0 commit comments

Comments
 (0)