Skip to content

Add Workflow to Tag Issues Missing Area Labels #78197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/labeler-missing-area-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "Spot Issues Missing Area Labels"

on:
workflow_dispatch:
schedule:
- cron: '0 13 * * *' # Runs daily at 13:00 UTC

permissions:
issues: write
contents: read

jobs:
check-area-labels:
name: "Check Issues Missing Area Labels"
runs-on: ubuntu-latest

if: github.repository == 'dotnet/roslyn' # Skip forks

steps:
- name: Tag Issues Missing Area Labels
uses: actions/github-script@v7
with:
script: |
const NEEDS_AREA_LABEL = 'needs-area-label';

// Fetch open issues in the repo
const issues = await github.paginate(
github.rest.issues.listForRepo,
{
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100,
}
);

for (const issue of issues) {
// Skip pull requests
if (issue.pull_request) continue;

const labels = issue.labels.map(label => label.name);
const hasAreaLabel = labels.some(name => name.startsWith('Area-') || name.startsWith('Interactive-'));
const hasNeedsAreaLabel = labels.includes(NEEDS_AREA_LABEL);

// If issue needs an Area label
if (!hasAreaLabel && !hasNeedsAreaLabel) {
console.log(`Adding '${NEEDS_AREA_LABEL}' to issue #${issue.number}`);

// Add the needs_area_label
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: [NEEDS_AREA_LABEL],
});
}
}