Merge branch 'main' into graphql/projectv2

This commit is contained in:
Lukasz Warchol
2022-06-27 14:53:57 +00:00
committed by GitHub
12 changed files with 350 additions and 196 deletions

View File

@@ -35,7 +35,7 @@ export async function addToProject(): Promise<void> {
core
.getInput('labeled')
.split(',')
.map(l => l.trim())
.map(l => l.trim().toLowerCase())
.filter(l => l.length > 0) ?? []
const labelOperator = core.getInput('label-operator').trim().toLocaleLowerCase()
@@ -43,7 +43,7 @@ export async function addToProject(): Promise<void> {
const urlMatch = projectUrl.match(urlParse)
const issue = github.context.payload.issue ?? github.context.payload.pull_request
const issueLabels: string[] = (issue?.labels ?? []).map((l: {name: string}) => l.name)
const issueLabels: string[] = (issue?.labels ?? []).map((l: {name: string}) => l.name.toLowerCase())
// Ensure the issue matches our `labeled` filter based on the label-operator.
if (labelOperator === 'and') {
@@ -51,6 +51,11 @@ export async function addToProject(): Promise<void> {
core.info(`Skipping issue ${issue?.number} because it doesn't match all the labels: ${labeled.join(', ')}`)
return
}
} else if (labelOperator === 'not') {
if (labeled.length > 0 && issueLabels.some(l => labeled.includes(l))) {
core.info(`Skipping issue ${issue?.number} because it contains one of the labels: ${labeled.join(', ')}`)
return
}
} else {
if (labeled.length > 0 && !issueLabels.some(l => labeled.includes(l))) {
core.info(`Skipping issue ${issue?.number} because it does not have one of the labels: ${labeled.join(', ')}`)