Fix auto-label action comments

This commit is contained in:
Scott Lahteine 2023-12-03 01:22:14 -06:00
parent dde878db04
commit 1c1c473910

View file

@ -20,21 +20,18 @@ jobs:
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
# Get all open issues in this repository // Get all open issues in this repository
const issueList = await github.rest.issues.listForRepo({ const issueList = await github.rest.issues.listForRepo({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
state: 'open' state: 'open'
}); });
# Filter the list of issues to only those that don't have any labels // Filter issues without labels that have a title containing '[BUG]'.
# and have a title that contains '[BUG]'. Only the first 50 issues.
const matchingIssues = issueList.data.filter( const matchingIssues = issueList.data.filter(
issue => issue.title.includes('[BUG]') && issue.labels.length === 0 issue => issue.title.includes('[BUG]') && issue.labels.length === 0
); );
# Process the first 50 // Process the first 50
for (const issue of matchingIssues.slice(0, 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({ await github.rest.issues.addLabels({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,