Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an issue to a project when a milestone is assigned #104

Open
cristiangsp opened this issue Jul 8, 2022 · 0 comments
Open

Add an issue to a project when a milestone is assigned #104

cristiangsp opened this issue Jul 8, 2022 · 0 comments

Comments

@cristiangsp
Copy link

cristiangsp commented Jul 8, 2022

I wanted to create an automated workflow in some repositories I'm working on so an issue gets added to a new Beta Project whenever it's assigned to a milestone (no matter which one). I found this repository and I think the Commands functionality could be extended so it provides the behaviour I'm looking for in a reusable way.

I started looking into the code and the path seemed straightforward. Adding the onMilestoned handler and in the Commands.ts file ensuring that the match method would let my case go through and end up executing the addToProject action in the perform method.

Also for the command format I was thinking on something like this:

{
  "type": "milestone",
  "action": "addToProject",
  "addToProject": {
    "url": "https://github.com/orgs/grafana/projects/76",
    "column": "To Do"
  }
}

Then I realised that there is some logic that basically prevents certain actions to be performed if there is not a label based interaction. For example, before executing the addToProject command in the perform method there is the following check:

if (
    command.action === 'addToProject' &&
    command.addToProject &&
    command.addToProject.url &&
    issue.labels.includes(command.name)
    ) {
        const projectId = getProjectIdFromUrl(command.addToProject.url)
         ....
    }

The issue.labels.includes(command.name) portion of the conditional would make my case fail as no label actions will be involved. Actually I think that logic must be in the matches logic not in the perform method so we can keep the command validation in one place.

So before jumping into a PR I wanted to double check that I'm not missing anything or maybe what I'm trying to accomplish does not make sense.

Thanks!

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

No branches or pull requests

1 participant