Skip to content

[docs] Add sticky headers recipe to RichTreeView customization #13906

[docs] Add sticky headers recipe to RichTreeView customization

[docs] Add sticky headers recipe to RichTreeView customization #13906

name: Check PR labels and title sync
on:
pull_request:
types: [opened, reopened, labeled, unlabeled, edited, synchronize]
permissions: {}
jobs:
check_label_title_sync:
runs-on: ubuntu-latest
name: Check label and title sync
steps:
- name: Check label matches title
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const pr = context.payload.pull_request;
const title = pr.title.toLowerCase();
const existingLabels =
pr.labels?.map((label) => label.name.toLowerCase()) || [];
const titleLabels = Array.from(
title.matchAll(/(?:\[([^\]]+)\])/g),
(match) => match[1]
);
const expectedLabelsFromTitle = titleLabels
.map((label) => {
if (label.endsWith("-pro")) {
return "plan: Pro";
}
if (label.endsWith("-premium")) {
return "plan: Premium";
}
if (label === "docs") {
return "docs";
}
return null;
})
.filter(Boolean);
if (expectedLabelsFromTitle.length === 0) {
return;
}
const missingLabels = expectedLabelsFromTitle.filter(
(label) => !existingLabels.includes(label.toLowerCase())
);
if (
missingLabels.length > 0
) {
core.setFailed(
`Title indicates labels that are missing: [${missingLabels.join(
", "
)}]. Please add them to the PR labels.`
);
} else {
core.info('No missing labels detected based on title.');
}