octonode icon indicating copy to clipboard operation
octonode copied to clipboard

Add issue to a project?

Open nickiannone-tw opened this issue 2 years ago • 8 comments

I've got a Hubot instance with a set of scripts which use octonode to sync Slack messages with GitHub Enterprise issues. I'm trying to add a piece of code to add an Issue to an existing Project, and let it auto-triage to To Do status, but I'm unable to achieve this by setting the project field on the issue and using the update method. How would I add this Issue to a Project with a known ID?

Current (non-working) code:

issue = client().issue REPO, id
project = client().project REPO, 1 # We want <repo>/projects/1!
issue.update { project: project }, (err, data, headers) ->
  unless err?
    res.send "Added issue ##{id} to project 1"
  else
    res.reply "Error"

I'm getting the success response from my GHE instance, but the issue isn't being assigned to the project. Is there another way to assign an issue to a project, or is this just currently unsupported?

nickiannone-tw avatar Jun 06 '22 14:06 nickiannone-tw

Possible alternative (haven't read through it yet): https://www.cloudwithchris.com/blog/automate-adding-gh-issues-projects-beta/

nickiannone-tw avatar Jun 06 '22 14:06 nickiannone-tw

Okay, so it looks like we have to get the project, list its columns, and PUT a new Card onto the project at that column. Not sure if there's a default auto-triage column abstraction which is listed somewhere, which corresponds to the default behavior on the web interface, but I'll experiment to find out.

Web interface:

Actions:

  • Go to Issue view for an issue
  • Click the gear on the Projects block on the right-hand sidebar
  • Click on the Project under the Repo Projects tab (which is selected by default)

Expected Outcome:

  • A Card is created which specifies the current issue, and added temporarily to a column called "Awaiting triage"
  • The Project's column automations add it to our "To Do" column

nickiannone-tw avatar Jun 06 '22 15:06 nickiannone-tw

Get project: https://docs.github.com/en/rest/projects/projects#get-a-project

List its columns: https://docs.github.com/en/rest/projects/columns#list-project-columns

Find auto-triage column: ???

Create a card: https://docs.github.com/en/rest/projects/cards#create-a-project-card

After these steps, the issue should show the project and column on the Issue view in GHE, I just need to confirm.

nickiannone-tw avatar Jun 06 '22 15:06 nickiannone-tw

Find auto-triage column: ???

I don't think I can help you with this. I think the column's probably named by default as "To Do"

pksunkara avatar Jun 06 '22 19:06 pksunkara

Why was this closed? We don't have a way to get the columns in a project, and I was going to add one to a new PR...

We still need to add support in Octonode for these endpoints, in order to achieve this functionality:

  • https://docs.github.com/en/rest/projects/columns
  • https://docs.github.com/en/rest/projects/projects
  • https://docs.github.com/en/rest/projects/cards

nickiannone-tw avatar Jun 06 '22 21:06 nickiannone-tw

I've got a few hours this evening I can set aside to spin up a PR for this; testing should be pretty much identical to what's already done, so I can probably close this out by end of week.

nickiannone-tw avatar Jun 06 '22 21:06 nickiannone-tw

Thanks; sorry for not being clearer with the original request. I'll dig into this in a few hours and see where I get in a few pomodoro cycles.

nickiannone-tw avatar Jun 06 '22 21:06 nickiannone-tw

FWIW, I would suggest using client.get and other such methods to build custom API calls. I am fine if you want to make a PR to the project to actually add those APIs too but I am just pointing out that we have a general abstraction that you can use.

pksunkara avatar Jun 06 '22 21:06 pksunkara