Skip to content

Commit

Permalink
Merge pull request #6 from kin/cj/allow-issues-to-accept-column-name-…
Browse files Browse the repository at this point in the history
…or-id

Allow action to accept a id or name
  • Loading branch information
carbroj authored Sep 28, 2021
2 parents 05b10c1 + 5aacea5 commit 3837410
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
target-column:
description: 'Case insensitive string with name of the column in the project issues should be moved to'
required: true
target-column-id:
description: 'Id of the column in the project issues should be moved to'
required: false
issues:
description: 'Optional arrray of issue event/webhook payloads as an alternative to using the trigger event payload'
required: false
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ try {
const parsedInput = JSON.parse(inputIssues);
const project = core.getInput("project-name");
const columnName = core.getInput("target-column");
const columnId = core.getInput("target-column-id");

const payload = parsedInput.length != 0 ? parsedInput : github.context.payload;
core.info(`payload: ${payload}`);
Expand All @@ -102,7 +103,11 @@ try {
// Find target column
const { repository: { projects: { edges: projectEdges } } }= await getColumnIds(repoOwner, repo, project);
const columns = projectEdges.flatMap(p => p.node.columns.edges).map(c => c.node);
const targetColumn = columns.find(c => c.name.toLowerCase() == columnName.toLowerCase());
const targetColumn = if (typeof columnId !== 'undefined') {
columns.find(c => c.id == columnId);
} else {
columns.find(c => c.name.toLowerCase() == columnName.toLowerCase());
}

// Find card ids for issues
const issueIds = issues.map(i => i.issue.node_id);
Expand Down

0 comments on commit 3837410

Please sign in to comment.