From 37fa44d53da13276a6fabdfefc4f399fb4785015 Mon Sep 17 00:00:00 2001 From: Sarah Edwards Date: Thu, 4 Mar 2021 14:57:18 -0800 Subject: [PATCH] Add slash command and workflow to remove issue or PR from FR board (#18101) --- .github/allowed-actions.js | 1 + .github/commands/remove.yaml | 10 ++++ .github/workflows/remove-from-fr-board.yaml | 64 +++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 .github/commands/remove.yaml create mode 100644 .github/workflows/remove-from-fr-board.yaml diff --git a/.github/allowed-actions.js b/.github/allowed-actions.js index f36a680b34..f79587f683 100644 --- a/.github/allowed-actions.js +++ b/.github/allowed-actions.js @@ -26,6 +26,7 @@ module.exports = [ "juliangruber/find-pull-request-action@2fc55e82a6d5d36fe1e7f1848f7e64fd02d99de9", "juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512", "lee-dohm/close-matching-issues@22002609b2555fe18f52b8e2e7c07cbf5529e8a8", + "octokit/graphql-action@5b3e01d42dee4509b0ac6b1cb2cf7778cdce85c2", "pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07", //pascalgn/automerge@0.12.0 "peter-evans/create-issue-from-file@a04ce672e3acedb1f8e416b46716ddfd09905326", "peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd", diff --git a/.github/commands/remove.yaml b/.github/commands/remove.yaml new file mode 100644 index 0000000000..e527282ee3 --- /dev/null +++ b/.github/commands/remove.yaml @@ -0,0 +1,10 @@ +trigger: remove-from-fr-board +title: Remove from FR board +description: Remove the current issue or pull request from the project board for the docs content first responder +surfaces: + - issue + - pull_request + - discussion +steps: + - type: repository_dispatch + eventType: remove_from_FR_board diff --git a/.github/workflows/remove-from-fr-board.yaml b/.github/workflows/remove-from-fr-board.yaml new file mode 100644 index 0000000000..39f29c017e --- /dev/null +++ b/.github/workflows/remove-from-fr-board.yaml @@ -0,0 +1,64 @@ +name: Remove card from FR board + +on: + repository_dispatch: + types: remove_from_FR_board + +jobs: + remove_from_FR_board: + if: github.repository == 'github/docs-internal' + runs-on: ubuntu-latest + steps: + - id: find_project_cards + uses: octokit/graphql-action@5b3e01d42dee4509b0ac6b1cb2cf7778cdce85c2 + with: + query: | + query($issue_node_id:ID!) { + node(id:$issue_node_id) { + ... on Issue { + projectCards(first: 10) { + nodes { + id + project { + name + id + } + } + } + } + ... on PullRequest { + projectCards(first: 10) { + nodes { + id + project { + name + id + } + } + } + } + } + } + issue_node_id: ${{ github.event.client_payload.command.resource.id }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: "echo 'Project cards found: ${{ steps.find_project_cards.outputs.data }}'" + + - name: Get FR card + env: + QUERY_DATA: ${{ steps.find_project_cards.outputs.data }} + run: | + echo 'FR_CARDS='$(jq '.node.projectCards.nodes | .[] | select(.project.id == "MDc6UHJvamVjdDQ1NzI0ODI") | .id' <<< "$QUERY_DATA") >> $GITHUB_ENV + + - name: Delete card + id: delete_project_card + if: ${{ env.FR_CARDS }} + uses: octokit/graphql-action@5b3e01d42dee4509b0ac6b1cb2cf7778cdce85c2 + with: + query: | + mutation DeleteCard { + deleteProjectCard(input:{cardId:${{ env.FR_CARDS }}}) {deletedCardId} + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}