octonode
octonode copied to clipboard
Add issue to a project?
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?
Possible alternative (haven't read through it yet): https://www.cloudwithchris.com/blog/automate-adding-gh-issues-projects-beta/
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
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.
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"
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
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.
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.
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.