diff --git a/README.md b/README.md index 61b0e5d..35506a2 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ linked-comments-previous-issue-text:::optional-->action(Issue Bot Action):::acti rotate-assignees:::optional-->action(Issue Bot Action):::action action(Issue Bot Action)-->issue-number:::output action(Issue Bot Action)-->previous-issue-number:::output +action(Issue Bot Action)-->project-v2-issue-item-id:::output classDef required fill:#6ba06a,stroke:#333,stroke-width:3px classDef optional fill:#d9b430,stroke:#333,stroke-width:3px classDef action fill:blue,stroke:#333,stroke-width:3px,color:#ffffff @@ -107,6 +108,7 @@ click linked-comments-previous-issue-text "https://github.com/imjohnbo/issue-bot click rotate-assignees "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L96" click issue-number "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L104" click previous-issue-number "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L107" +click project-v2-issue-item-id "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L117" ``` diff --git a/action.yml b/action.yml index 7576819..e4d087a 100644 --- a/action.yml +++ b/action.yml @@ -114,6 +114,8 @@ outputs: previous-issue-number: description: 'The issue number of the previous issue, if available' + project-v2-issue-item-id: + description: 'The issue item id of the Projects v2, if available' runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index b9e7fb6..8d050ac 100644 --- a/dist/index.js +++ b/dist/index.js @@ -398,6 +398,7 @@ const run = async (inputs) => { core.info(`Running with inputs: ${JSON.stringify(inputs)}`); let previousAssignee; let previousIssueNumber = -1; let previousIssueNodeId; let previousAssignees; + let projectV2IssueItemId; if (needPreviousIssue(inputs.pinned, inputs.closePrevious, inputs.rotateAssignees, inputs.linkedComments)) { ({ previousIssueNumber, previousIssueNodeId, previousAssignees } = await getPreviousIssue(inputs.labels)); @@ -422,10 +423,11 @@ const run = async (inputs) => { } if (inputs.projectV2) { - await addIssueToProjectV2({ + const response = await addIssueToProjectV2({ issueNodeId: newIssueNodeId, url: inputs.projectV2 }); + projectV2IssueItemId = response.addProjectV2ItemById.item.id; } if (inputs.milestone) { @@ -470,6 +472,11 @@ const run = async (inputs) => { core.info(`Previous issue number: ${previousIssueNumber}`); core.setOutput('previous-issue-number', String(previousIssueNumber)); } + + if (projectV2IssueItemId) { + core.info(`Project V2 Issue Item Id: ${projectV2IssueItemId}`); + core.setOutput('project-v2-issue-item-id', projectV2IssueItemId); + } } catch (error) { core.setFailed(`Error encountered: ${error}.`); } diff --git a/lib/issue-bot.js b/lib/issue-bot.js index b3b7bab..873e70a 100644 --- a/lib/issue-bot.js +++ b/lib/issue-bot.js @@ -391,6 +391,7 @@ const run = async (inputs) => { core.info(`Running with inputs: ${JSON.stringify(inputs)}`); let previousAssignee; let previousIssueNumber = -1; let previousIssueNodeId; let previousAssignees; + let projectV2IssueItemId; if (needPreviousIssue(inputs.pinned, inputs.closePrevious, inputs.rotateAssignees, inputs.linkedComments)) { ({ previousIssueNumber, previousIssueNodeId, previousAssignees } = await getPreviousIssue(inputs.labels)); @@ -415,10 +416,11 @@ const run = async (inputs) => { } if (inputs.projectV2) { - await addIssueToProjectV2({ + const response = await addIssueToProjectV2({ issueNodeId: newIssueNodeId, url: inputs.projectV2 }); + projectV2IssueItemId = response.addProjectV2ItemById.item.id; } if (inputs.milestone) { @@ -463,6 +465,11 @@ const run = async (inputs) => { core.info(`Previous issue number: ${previousIssueNumber}`); core.setOutput('previous-issue-number', String(previousIssueNumber)); } + + if (projectV2IssueItemId) { + core.info(`Project V2 Issue Item Id: ${projectV2IssueItemId}`); + core.setOutput('project-v2-issue-item-id', projectV2IssueItemId); + } } catch (error) { core.setFailed(`Error encountered: ${error}.`); }