diff --git a/.github/workflows/RemoveClosedIssuesFromProject.yaml b/.github/workflows/RemoveClosedIssuesFromProject.yaml new file mode 100644 index 00000000000..a5df9432778 --- /dev/null +++ b/.github/workflows/RemoveClosedIssuesFromProject.yaml @@ -0,0 +1,52 @@ +name: Remove issue from project on specific close reasons + +on: + issues: + types: [closed] + +jobs: + delete-project-item: + runs-on: ubuntu-latest + if: ${{ github.event.issue.state_reason == 'duplicate' || github.event.issue.state_reason == 'not_planned' }} + permissions: + contents: read + issues: write + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG: ${{ github.repository_owner }} + PROJECT_NUMBER: 524 # https://github.com/orgs/dotnet/projects/524 + ISSUE_NUMBER: ${{ github.event.issue.number }} + steps: + - name: Get issue items and close + run: | + # Get all project items associated with the issue + QUERY=' + query FindProjectItemForIssue($owner: String!, $repo: String!, $issueNumber: Int!) { + repository(owner: $owner, name: $repo) { + issue(number: $issueNumber) { + projectItems(first: 20) { + nodes { + id + project { + number + } + } + } + } + } + } + ' + + RESULT=$(gh api graphql -f owner=$ORG -f repo=$REPO -F issueNumber=$ISSUE_NUMBER -f query="$QUERY") + + # If the issue is on more than one project board, we'll receive multiple item results. + # Iterate over these and close the item with the correct project number. + echo $RESULT | jq -c '.data.repository.issue.projectItems.nodes[]' | while read -r obj; do + item_id=$(echo "$obj" | jq -r '.id') + project_number=$(echo "$obj" | jq '.project.number') + + if [ "$project_number" -eq $PROJECT_NUMBER ]; then + echo "Closing project item with node id ${item_id} for issue $ISSUE_NUMBER" + gh project item-delete $PROJECT_NUMBER --id $item_id --owner $ORG + fi + done diff --git a/EFCore.sln b/EFCore.sln index fecc4fafa42..004fa7b620a 100644 --- a/EFCore.sln +++ b/EFCore.sln @@ -147,6 +147,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.Tasks", "src\EFCore. EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "EFCore.FSharp.FunctionalTests", "test\EFCore.FSharp.FunctionalTests\EFCore.FSharp.FunctionalTests.fsproj", "{89180105-1D98-4844-9C24-3A5DA2C53329}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github Workflows", "Github Workflows", "{28057041-CE74-A1DE-B319-31CF69B5168A}" + ProjectSection(SolutionItems) = preProject + .github\workflows\TestCosmos.yaml = .github\workflows\TestCosmos.yaml + .github\workflows\RemoveClosedIssuesFromProject.yaml = .github\workflows\RemoveClosedIssuesFromProject.yaml + .github\workflows\inter-branch-merge-flow.yml = .github\workflows\inter-branch-merge-flow.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -444,6 +451,7 @@ Global {2AC6A8AC-5C0A-422A-B21A-CDC8D75F20A3} = {258D5057-81B9-40EC-A872-D21E27452749} {711EE8F3-F92D-4470-8B0B-25D8B13EF282} = {CE6B50B2-34AE-44C9-940A-4E48C3E1B3BC} {89180105-1D98-4844-9C24-3A5DA2C53329} = {258D5057-81B9-40EC-A872-D21E27452749} + {28057041-CE74-A1DE-B319-31CF69B5168A} = {B9E4CC99-199C-4E3B-9EC5-D1FDFCD6C27B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {285A5EB4-BCF4-40EB-B9E1-DF6DBCB5E705}