From 95821b07b11fc94c00269cbab075bec8b1b6c05a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 29 Nov 2023 16:45:37 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Auto-label=20older=20open=20[BUG]?= =?UTF-8?q?=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-label.yml | 42 +++++++++++++++++++++++++++++++ .github/workflows/close-stale.yml | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/auto-label.yml diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml new file mode 100644 index 00000000000..f3a752da3d4 --- /dev/null +++ b/.github/workflows/auto-label.yml @@ -0,0 +1,42 @@ +# +# auto-label.yml +# - Find all open issues without a label and a title containing "[BUG]". +# - Apply the label "Bug: Potential ?" to these issues. +# + +on: + schedule: + - cron: "30 8 * * *" + +jobs: + autolabel: + name: Auto Label + if: github.repository == 'MarlinFirmware/Marlin' + runs-on: ubuntu-latest + steps: + - name: Auto Label for [BUG] + uses: actions/github-script@v5 + with: + script: | + # Get all open issues in this repository + const issueList = await github.rest.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + # Filter the list of issues to only those that don't have any labels + # and have a title that contains '[BUG]'. Only the first 50 issues. + const matchingIssues = issueList.data.filter( + issue => issue.title.includes('[BUG]') && issue.labels.length === 0 + ); + # Process the first 50 + for (const issue of matchingIssues.slice(0, 50)) { + // Run the desired action on the issue + // For example, to add a label: + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + labels: ['Bug: Potential ?'] + }); + } diff --git a/.github/workflows/close-stale.yml b/.github/workflows/close-stale.yml index ef1b33b4eb1..397f9b5ea6c 100644 --- a/.github/workflows/close-stale.yml +++ b/.github/workflows/close-stale.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/stale@v3 + - uses: actions/stale@v8 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: |