Skip to content

Commit

Permalink
Add quality-scale label for PRs touching quality_scale.yaml (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Nov 21, 2024
1 parent cf6680d commit 814cd40
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions services/bots/src/github-webhook/handlers/quality_scale.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IssuesLabeledEvent, PullRequestLabeledEvent } from '@octokit/webhooks-types';
import { EventType, HomeAssistantRepository } from '../github-webhook.const';
import { WebhookContext } from '../github-webhook.model';
import { fetchPullRequestFilesFromContext } from '../utils/pull_request';
import { BaseWebhookHandler } from './base';

import { fetchIntegrationManifest, QualityScale } from '../utils/integration';
Expand All @@ -10,6 +11,16 @@ export class QualityScaleLabeler extends BaseWebhookHandler {
public allowedRepositories = [HomeAssistantRepository.CORE];

async handle(context: WebhookContext<IssuesLabeledEvent | PullRequestLabeledEvent>) {
const files = await fetchPullRequestFilesFromContext(context);
const filenames = files.map((file) => {
const parts = file.filename.split('/');
return parts[parts.length - 1];
});

if (filenames.includes('quality_scale.yaml')) {
context.scheduleIssueLabel('quality-scale');
}

if (!context.payload.label || !context.payload.label.name.startsWith('integration: ')) {
return;
}
Expand Down

0 comments on commit 814cd40

Please sign in to comment.