From 6f0311f20fda3c0d7486cb93e609a32e0f7e30f5 Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 16 Dec 2021 13:44:14 +0100 Subject: [PATCH] fix --- .github/workflows/assign-to-project.yml | 26 +++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/assign-to-project.yml b/.github/workflows/assign-to-project.yml index 2ffddad..837d4aa 100644 --- a/.github/workflows/assign-to-project.yml +++ b/.github/workflows/assign-to-project.yml @@ -34,18 +34,28 @@ jobs: const project_name = 'test-project' const column_name = 'To do' + function firstOrDefault(items, predicate) { + for (const item of items) { + if (predicate(item)) { + return item + } + } + return null + } + // find the project const projects = await github.projects.listForRepo({ owner: context.repo.owner, repo: context.repo.repo, }) - var project = null - for (const p of projects) { - if (p.name === project_name) { - project = p - } - } - if (p === null) { + const project = firstOrDefault(projects, (x) => x.name === project_name) + //var project = null + //for (const p of projects) { + // if (p.name === project_name) { + // project = p + // } + //} + if (project === null) { core.setFailed(`Failed to find project "${project_name}".`) return } @@ -60,7 +70,7 @@ jobs: column = c } } - if (c === null) { + if (column === null) { core.setFailed(`Failed to find column "${column_name}" in project ${project.name}.`) return }