auto-label.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #
  2. # auto-label.yml
  3. # - Find all open issues without a label and a title containing "[BUG]".
  4. # - Apply the label "Bug: Potential ?" to these issues.
  5. #
  6. name: Label Old Bugs
  7. on:
  8. schedule:
  9. - cron: "30 8 * * *"
  10. jobs:
  11. autolabel:
  12. name: Auto Label
  13. if: github.repository == 'MarlinFirmware/Marlin'
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Auto Label for [BUG]
  17. uses: actions/github-script@v7
  18. with:
  19. script: |
  20. # Get all open issues in this repository
  21. const issueList = await github.rest.issues.listForRepo({
  22. owner: context.repo.owner,
  23. repo: context.repo.repo,
  24. state: 'open'
  25. });
  26. # Filter the list of issues to only those that don't have any labels
  27. # and have a title that contains '[BUG]'. Only the first 50 issues.
  28. const matchingIssues = issueList.data.filter(
  29. issue => issue.title.includes('[BUG]') && issue.labels.length === 0
  30. );
  31. # Process the first 50
  32. for (const issue of matchingIssues.slice(0, 50)) {
  33. // Run the desired action on the issue
  34. // For example, to add a label:
  35. await github.rest.issues.addLabels({
  36. owner: context.repo.owner,
  37. repo: context.repo.repo,
  38. issue_number: issue.number,
  39. labels: ['Bug: Potential ?']
  40. });
  41. }