auto-label.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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-22.04
  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 issues without labels that have a title containing '[BUG]'.
  27. const matchingIssues = issueList.data.filter(
  28. issue => issue.title.includes('[BUG]') && issue.labels.length === 0
  29. );
  30. // Process the first 50
  31. for (const issue of matchingIssues.slice(0, 50)) {
  32. await github.rest.issues.addLabels({
  33. owner: context.repo.owner,
  34. repo: context.repo.repo,
  35. issue_number: issue.number,
  36. labels: ['Bug: Potential ?']
  37. });
  38. }