Add workflow to automatically label pending backports

This commit is contained in:
Janek Bevendorff authored and Janek Bevendorff committed 2026-11-13 20:33:01 +01:00
1 parent 6f97143a0b
commit d4c3eb359a
1 file changed
+33
+33
View File
@@ -0,0 +1,33 @@
name: "Auto-label backport Pull Requests"
on:
pull_request:
types: [closed]
permissions:
pull-requests: write
jobs:
label:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Add backport-pending label
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
// Match patch releases, e.g. v2.8.1, but not v2.8.0.
const milestone = pr.milestone?.title ?? "";
const isPatchRelease = /^v\d+\.\d+\.[1-9]\d*$/.test(milestone);
const labels = pr.labels.map(l => l.name);
if (isPatchRelease && !labels.includes("pr: backported") && !labels.includes("pr: backport-queue")) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ["pr: backport-pending"]
});
}