From 42d62594ac5f5775adc1c88754bf3468cf599ffc Mon Sep 17 00:00:00 2001 From: Michel Engelen <32863416+michelengelen@users.noreply.github.com> Date: Mon, 16 Sep 2024 19:47:31 +0200 Subject: [PATCH] [infra] Adds reusable workflow for issue cleanup (#597) --- .github/workflows/issue-cleanup.yml | 52 -------------------------- .github/workflows/new-issue-triage.yml | 15 ++++++++ 2 files changed, 15 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/issue-cleanup.yml create mode 100644 .github/workflows/new-issue-triage.yml diff --git a/.github/workflows/issue-cleanup.yml b/.github/workflows/issue-cleanup.yml deleted file mode 100644 index 0da67dc0a..000000000 --- a/.github/workflows/issue-cleanup.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Cleanup issue comment - -on: - issues: - types: - - opened - -permissions: {} - -jobs: - issue_cleanup: - runs-on: ubuntu-latest - permissions: - issues: write - steps: - - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 - with: - script: | - const issue = await github.rest.issues.get({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - }) - - const lines = issue.data.body.split('\n') - - const _ = extractInputSection(lines, 'Latest version') - const searchKeywords = extractInputSection(lines, 'Search keywords') - const orderID = extractInputSection(lines, 'Order ID or Support key') - - lines.push('') - lines.push('**Search keywords**: ' + searchKeywords) - if (orderID !== '' && orderID !== '_No response_') { - lines.push('**Order ID**: ' + orderID) - } - - const body = lines.join('\n') - - await github.rest.issues.update({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body, - }) - - function extractInputSection(lines, title) { - const index = lines.findIndex(line => line.startsWith('###') && line.includes(title)) - if (index === -1) { - return '' - } - return lines.splice(index, 4)[2].trim() - } diff --git a/.github/workflows/new-issue-triage.yml b/.github/workflows/new-issue-triage.yml new file mode 100644 index 000000000..a7e374f14 --- /dev/null +++ b/.github/workflows/new-issue-triage.yml @@ -0,0 +1,15 @@ +name: New issue triage +on: + issues: + types: + - opened + +permissions: {} + +jobs: + issue_cleanup: + name: Clean issue body + uses: mui/mui-public/.github/workflows/issues_body-cleanup.yml@master + permissions: + contents: read + issues: write