mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
ci: simplify label PR workflow (#25579)
This commit is contained in:
parent
be7d43034b
commit
c41acfb7ca
26
.github/workflows/label-pr.yml
vendored
26
.github/workflows/label-pr.yml
vendored
@ -6,7 +6,6 @@ on:
|
|||||||
- opened
|
- opened
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- 2.x
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
add-pr-labels:
|
add-pr-labels:
|
||||||
@ -24,27 +23,20 @@ jobs:
|
|||||||
const labelsToAdd = []
|
const labelsToAdd = []
|
||||||
|
|
||||||
const pullRequest = {
|
const pullRequest = {
|
||||||
baseLabel: '${{ github.event.pull_request.base.label }}',
|
|
||||||
number: ${{ github.event.pull_request.number }},
|
number: ${{ github.event.pull_request.number }},
|
||||||
title: process.env.PULL_REQUEST_TITLE,
|
title: process.env.PULL_REQUEST_TITLE,
|
||||||
labelsNames: ${{ toJson(github.event.pull_request.labels.*.name) }}
|
labelsNames: ${{ toJson(github.event.pull_request.labels.*.name) }}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select label based on the branch name
|
// Select label based on the name of the base branch
|
||||||
const branchNameBasedLabelName = {
|
const baseBranchLabelName = '3.x'
|
||||||
'nuxt:main': '3.x',
|
|
||||||
'nuxt:2.x': '2.x'
|
|
||||||
}[pullRequest.baseLabel]
|
|
||||||
|
|
||||||
if (
|
if (!pullRequest.labelsNames.includes(baseBranchLabelName)) {
|
||||||
branchNameBasedLabelName &&
|
labelsToAdd.push(baseBranchLabelName)
|
||||||
!pullRequest.labelsNames.includes(branchNameBasedLabelName)
|
|
||||||
) {
|
|
||||||
labelsToAdd.push(branchNameBasedLabelName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select label based on the type in PR title
|
// Select label based on the type in PR title
|
||||||
const eligibleTypesToLabelsNamesMap = {
|
const pullRequestTypeToLabelName = {
|
||||||
chore: 'chore',
|
chore: 'chore',
|
||||||
ci: 'chore',
|
ci: 'chore',
|
||||||
docs: 'documentation',
|
docs: 'documentation',
|
||||||
@ -55,13 +47,13 @@ jobs:
|
|||||||
test: 'test'
|
test: 'test'
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [eligibleType, labelName] of Object.entries(
|
for (const [pullRequestType, labelName] of Object.entries(
|
||||||
eligibleTypesToLabelsNamesMap
|
pullRequestTypeToLabelName
|
||||||
)) {
|
)) {
|
||||||
if (
|
if (
|
||||||
pullRequest.title.startsWith(eligibleType) &&
|
pullRequest.title.startsWith(pullRequestType) &&
|
||||||
!pullRequest.labelsNames.includes(
|
!pullRequest.labelsNames.includes(
|
||||||
eligibleTypesToLabelsNamesMap[eligibleType]
|
pullRequestTypeToLabelName[pullRequestType]
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
labelsToAdd.push(labelName)
|
labelsToAdd.push(labelName)
|
||||||
|
Loading…
Reference in New Issue
Block a user