Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/gardener_issue_comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on:
issue_comment:
types:
- created

jobs:
move-to-backlog:
name: Move done issues back to Gardener project board backlog
runs-on: ubuntu-latest
steps:
- name: Move issue back to backlog if status is Done
run: |
# ids fetched from https://docs.github.com/en/graphql/overview/explorer
project_id="PVT_kwDOAQFeYs4AAsTr" # Gardener
issue_id=${{ github.event.issue.node_id }}
status_field_id="PVTSSF_lADOAQFeYs4AAsTrzgAXRuU" # Status
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just awful 😄

backlog_option_id="f75ad846" # Backlog

# ensures that the issue is already on board but also seems to be the only way to fetch
# the item id
item_id="$(gh api graphql -f query='
mutation($project_id: ID!, $content_id: ID!) {
addProjectV2ItemById(input: {projectId: $project_id, contentId: $content_id}) {
item {
id
}
}
}' -f project_id="$project_id" -f content_id="$issue_id" -q '.data.addProjectV2ItemById.item.id'
")

current_status="$(gh api graphql -f query='
query($node_id: ID!) {
node(id: $item_id) {
... on ProjectV2Item {
fieldValueByName(name: "Status") {
... on ProjectV2ItemFieldSingleSelectValue {
name
}
}
}
}
}'
") -f item_id="$item_id" -q '.data.node.fieldValueByName.name'

if [[ "$current_status" = "Done" ]] ; then
echo "Moving issue from Done to Backlog"
gh api graphql -f query='
mutation($project_id: ID!, $item_id: ID!, $field_id: ID!, $option_id: String) {
updateProjectV2ItemFieldValue(
input: {
projectId: $project_id
itemId: $item_id
fieldId: $field_id
value: {
singleSelectOptionId: $option_id
}
}
) {
projectV2Item {
id
}
}
}' -f project_id="$project_id" -f item_id="$item_id" -f field_id="$status_field_id" -f option_id="$backlog_option_id"
else
echo "Issue already in $current_status"
fi