Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Add issue to a project? #361

Open
nickiannone-tw opened this issue Jun 6, 2022 · 8 comments
Open

Add issue to a project? #361

nickiannone-tw opened this issue Jun 6, 2022 · 8 comments

Comments

@nickiannone-tw
Copy link

nickiannone-tw commented Jun 6, 2022

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
Copy link
Author

nickiannone-tw commented Jun 6, 2022

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

@nickiannone-tw
Copy link
Author

nickiannone-tw commented Jun 6, 2022

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
Copy link
Author

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.

@pksunkara
Copy link
Owner

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"

@nickiannone-tw
Copy link
Author

nickiannone-tw commented Jun 6, 2022

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:

@nickiannone-tw
Copy link
Author

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.

@pksunkara pksunkara reopened this Jun 6, 2022
@nickiannone-tw
Copy link
Author

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.

@pksunkara
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants