From b2406f9defe1bc5378bbfbebb8e828968ef542a6 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 17 Jul 2025 17:15:28 +1200 Subject: [PATCH] [CI] Add ``needs-docs`` labelling (#9591) --- .github/workflows/auto-label-pr.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-label-pr.yml b/.github/workflows/auto-label-pr.yml index 83d66bb140..7c602d7056 100644 --- a/.github/workflows/auto-label-pr.yml +++ b/.github/workflows/auto-label-pr.yml @@ -4,7 +4,7 @@ on: # Runs only on pull_request_target due to having access to a App token. # This means PRs from forks will not be able to alter this workflow to get the tokens pull_request_target: - types: [labeled, opened, reopened, synchronize] + types: [labeled, opened, reopened, synchronize, edited] permissions: pull-requests: write @@ -124,6 +124,7 @@ jobs: 'by-code-owner', 'has-tests', 'needs-tests', + 'needs-docs', 'too-big', 'labeller-recheck' ].includes(label) @@ -377,6 +378,26 @@ jobs: } } + // Strategy: Documentation check for new components/platforms + if (labels.has('new-component') || labels.has('new-platform')) { + const prBody = context.payload.pull_request.body || ''; + + // Look for documentation PR links + // Patterns to match: + // - https://github.com/esphome/esphome-docs/pull/1234 + // - esphome/esphome-docs#1234 + const docsPrPatterns = [ + /https:\/\/github\.com\/esphome\/esphome-docs\/pull\/\d+/, + /esphome\/esphome-docs#\d+/ + ]; + + const hasDocsLink = docsPrPatterns.some(pattern => pattern.test(prBody)); + + if (!hasDocsLink) { + labels.add('needs-docs'); + } + } + // Convert Set to Array let finalLabels = Array.from(labels);