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);