Skip to content

Commit e81a4c7

Browse files
committed
Add github workflow to remove duplicate/not-planned issues from the project board
1 parent 83c6514 commit e81a4c7

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Remove issue from project on specific close reasons
2+
3+
on:
4+
issues:
5+
types: [closed]
6+
7+
jobs:
8+
delete-project-item:
9+
runs-on: ubuntu-latest
10+
if: ${{ github.event.issue.state_reason == 'duplicate' || github.event.issue.state_reason == 'not_planned' }}
11+
permissions:
12+
contents: read
13+
issues: write
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
ORG: ${{ github.repository_owner }}
17+
PROJECT_NUMBER: 524 # https://github.com/orgs/dotnet/projects/524
18+
ISSUE_NUMBER: ${{ github.event.issue.number }}
19+
steps:
20+
- name: Get issue items and close
21+
run: |
22+
# Get all project items associated with the issue
23+
QUERY='
24+
query FindProjectItemForIssue($owner: String!, $repo: String!, $issueNumber: Int!) {
25+
repository(owner: $owner, name: $repo) {
26+
issue(number: $issueNumber) {
27+
projectItems(first: 20) {
28+
nodes {
29+
id
30+
project {
31+
number
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
38+
'
39+
40+
RESULT=$(gh api graphql -f owner=$ORG -f repo=$REPO -F issueNumber=$ISSUE_NUMBER -f query="$QUERY")
41+
42+
# If the issue is on more than one project board, we'll receive multiple item results.
43+
# Iterate over these and close the item with the correct project number.
44+
echo $RESULT | jq -c '.data.repository.issue.projectItems.nodes[]' | while read -r obj; do
45+
item_id=$(echo "$obj" | jq -r '.id')
46+
project_number=$(echo "$obj" | jq '.project.number')
47+
48+
if [ "$project_number" -eq $PROJECT_NUMBER ]; then
49+
echo "Closing project item with node id ${item_id} for issue $ISSUE_NUMBER"
50+
gh project item-delete $PROJECT_NUMBER --id $item_id --owner $ORG
51+
fi
52+
done

EFCore.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.Tasks", "src\EFCore.
147147
EndProject
148148
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "EFCore.FSharp.FunctionalTests", "test\EFCore.FSharp.FunctionalTests\EFCore.FSharp.FunctionalTests.fsproj", "{89180105-1D98-4844-9C24-3A5DA2C53329}"
149149
EndProject
150+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github Workflows", "Github Workflows", "{28057041-CE74-A1DE-B319-31CF69B5168A}"
151+
ProjectSection(SolutionItems) = preProject
152+
.github\workflows\TestCosmos.yaml = .github\workflows\TestCosmos.yaml
153+
.github\workflows\RemoveClosedIssuesFromProject.yaml = .github\workflows\RemoveClosedIssuesFromProject.yaml
154+
.github\workflows\inter-branch-merge-flow.yml = .github\workflows\inter-branch-merge-flow.yml
155+
EndProjectSection
156+
EndProject
150157
Global
151158
GlobalSection(SolutionConfigurationPlatforms) = preSolution
152159
Debug|Any CPU = Debug|Any CPU
@@ -444,6 +451,7 @@ Global
444451
{2AC6A8AC-5C0A-422A-B21A-CDC8D75F20A3} = {258D5057-81B9-40EC-A872-D21E27452749}
445452
{711EE8F3-F92D-4470-8B0B-25D8B13EF282} = {CE6B50B2-34AE-44C9-940A-4E48C3E1B3BC}
446453
{89180105-1D98-4844-9C24-3A5DA2C53329} = {258D5057-81B9-40EC-A872-D21E27452749}
454+
{28057041-CE74-A1DE-B319-31CF69B5168A} = {B9E4CC99-199C-4E3B-9EC5-D1FDFCD6C27B}
447455
EndGlobalSection
448456
GlobalSection(ExtensibilityGlobals) = postSolution
449457
SolutionGuid = {285A5EB4-BCF4-40EB-B9E1-DF6DBCB5E705}

0 commit comments

Comments
 (0)