ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Turn all cards into issues

Open raulriera opened this issue 6 years ago • 8 comments

The process of creating a board, filling it with cards and then turn those cards into issues is pretty tedious. Specially annoying when I have to them duplicate the issues for iOS and Android (that app is already done tho 😉)

I don't know what kind of trigger this should be, or what should be the default behaviour since the cards don't have titles or any "rich formatting".

Any suggestions? I would love to get started on this

raulriera avatar Apr 15 '18 20:04 raulriera

Just so that I understand, you'd want this behavior, but for all notes in a project board?

image

Sounds neat! As you already know, probot-commands would help but its a bit of a weird connection to write a command in an issue that affects unrelated things.

What about listening for a project rename, to something like:

before: 'Project name'
after: '[convert] Project name'

Definitely hacky.

JasonEtco avatar Apr 15 '18 20:04 JasonEtco

Yes, exactly that... Do this work in bulk 🙂 ..

Ouuu I like the project rename thing

raulriera avatar Apr 15 '18 20:04 raulriera

You'd probably want to rename it back to the before when you're done too 😉

JasonEtco avatar Apr 15 '18 21:04 JasonEtco

@raulriera You can do that with GitKraken Glo which sync cards to issues a la Trello-style.

Berkmann18 avatar Jul 27 '18 01:07 Berkmann18

I just started exploring w/ Github projects and also was looking for how to convert all cards on a board into issues.

dblado avatar Jun 13 '19 17:06 dblado

I've just hacked something together from the demo project on Glitch that will autoconvert cards as they're created as opposed to the whole project at once, but might be of interest?

Go here: https://probot.github.io/docs/hello-world/ Click remix on Glitch

index.js

module.exports = (app) => {
  // Your code here
  app.log('Yay! The app was loaded!')

  // example of probot responding 'Hello World' to a new issue being opened
  app.on('project_card.created', async context => {
    // `context` extracts information from the event, which can be passed to
    // GitHub API calls. This will return:
    //   {owner: 'yourname', repo: 'yourrepo', number: 123, body: 'Hello World!}

    const old_card = context.payload.project_card
    if (!old_card.note) { // Prevent big loop!
      return
    }
    
    const req1 = await context.github.projects.deleteCard({
      card_id: old_card.id
    });

    const note_split = old_card.note.split("\r\n")
    const title = note_split[0];
    const body = note_split[1];
    const new_issue = await context.github.issues.create({
      owner: "CHANGEME",
      repo: "CHANGEME",
      title: title,
      body: body
    })

    const new_card = await context.github.projects.createCard({
      column_id: old_card.column_id,
      content_id: new_issue.data.id,
      content_type: "Issue"
    })
  })
}

app.yml

Change default_events to project_card Change default_permissions:

  • issues: write
  • metadata: read
  • repository_projects: write
  • organization_projects: write

adnathanail avatar Jan 27 '20 12:01 adnathanail

I asked in octokit/rest.js and in octokit/webhooks.js and they answer me. They explained to me there's no rest endpoint to make this action, otherwise there's a graphql mutation to do that. You could found an example here

await context.octokit.graphql(`
  mutation ($cardId: ID!, $repositoryId: ID!, $title: String, $body: String) {
    convertProjectCardNoteToIssue(input: {projectCardId: $cardId, repositoryId: $repositoryId, title: $title, body: $body}) {
      clientMutationId
    }
  }`,
{
  projectCardId: context.payload.project_card.id,
  repositoryId: context.payload.repository.id,
  // optional
  // title: 'new issue title', // defaults to card content
  // body: 'new issue description'
})

mirusky avatar Dec 12 '20 15:12 mirusky

Would love if there was a GitHub Action to do this

debola31 avatar Jun 30 '21 21:06 debola31