From 814cd407f120273008eeed806ba2997377874858 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 21 Nov 2024 08:50:53 +0100 Subject: [PATCH] Add quality-scale label for PRs touching quality_scale.yaml (#281) --- .../bots/src/github-webhook/handlers/quality_scale.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/bots/src/github-webhook/handlers/quality_scale.ts b/services/bots/src/github-webhook/handlers/quality_scale.ts index 8ac3a5b..5bd66cd 100644 --- a/services/bots/src/github-webhook/handlers/quality_scale.ts +++ b/services/bots/src/github-webhook/handlers/quality_scale.ts @@ -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'; @@ -10,6 +11,16 @@ export class QualityScaleLabeler extends BaseWebhookHandler { public allowedRepositories = [HomeAssistantRepository.CORE]; async handle(context: WebhookContext) { + 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; }