Giter Club home page Giter Club logo

issue-bot's Introduction

Issue Bot

GitHub Actions powered Issue Bot ๐Ÿฆพ

About

Work on a distributed team? Try using Issue Bot as a Scrum standup process automation bot to keep track of what you're all working on. ๐Ÿค–

Have repeated tasks you're setting reminders for elsewhere? Issue Bot's got your back there, too. ๐Ÿ‘

Or just need an issue created on a certain condition? Issue Bot is there when your CI build breaks. ๐Ÿ’”

Issue Bot is a flexible GitHub action that takes care of a few issue related tasks:

  • Opens new issue with title, body, labels, and assignees
  • Uses Mustache templating syntax in body, along with a couple of handy template variables: assignees and previousIssueNumber
  • Closes most recent previous issue with all labels if close-previous is true
  • Adds new issue to project (user, organization, or repository project based on value of project-type), column, and milestone
  • Adds new issue to user or organization project at project-v2-path
  • Pins new issue and unpins previous issue if pinned is true
  • Makes issue comments linking new and previous issues if linked-comments is true
  • Assigns new issue only to the next assignee in the list if rotate-assignees is true. Useful for duty rotation like first responder.
  • Pairs well with imjohnbo/extract-issue-template-fields if you'd prefer to open issues based on issue templates

v3 Migration

โš ๏ธ If you're a v2 user, please note that these breaking changes were introduced in v3: โš ๏ธ

and these features were added ๐ŸŽ‰:

As always, your feedback and contributions are welcome.

Usage

Simple example:

# ...
- name: Create new issue
  uses: imjohnbo/issue-bot@v3
  with:
    assignees: "octocat, monalisa"
    title: Hello, world
    body: |-
      :wave: Hi, {{#each assignees}}@{{this}}{{#unless @last}}, {{/unless}}{{/each}}!
    pinned: true
# ...

For more examples, see a GitHub-wide search or ./docs/example-workflows:

Inputs and outputs

See action.yml for full description of inputs and outputs.

Generated by imjohnbo/action-to-mermaid:

flowchart LR
token:::optional-->action(Issue Bot Action):::action
title:::required-->action(Issue Bot Action):::action
body:::optional-->action(Issue Bot Action):::action
labels:::optional-->action(Issue Bot Action):::action
assignees:::optional-->action(Issue Bot Action):::action
project-type:::optional-->action(Issue Bot Action):::action
project:::optional-->action(Issue Bot Action):::action
column:::optional-->action(Issue Bot Action):::action
milestone:::optional-->action(Issue Bot Action):::action
pinned:::optional-->action(Issue Bot Action):::action
close-previous:::optional-->action(Issue Bot Action):::action
linked-comments:::optional-->action(Issue Bot Action):::action
linked-comments-new-issue-text:::optional-->action(Issue Bot Action):::action
linked-comments-previous-issue-text:::optional-->action(Issue Bot Action):::action
rotate-assignees:::optional-->action(Issue Bot Action):::action
action(Issue Bot Action)-->issue-number:::output
action(Issue Bot Action)-->previous-issue-number:::output
action(Issue Bot Action)-->project-v2-issue-item-id:::output
classDef required fill:#6ba06a,stroke:#333,stroke-width:3px
classDef optional fill:#d9b430,stroke:#333,stroke-width:3px
classDef action fill:blue,stroke:#333,stroke-width:3px,color:#ffffff
classDef output fill:#fff,stroke:#333,stroke-width:3px,color:#333
click token "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L9"
click title "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L15"
click body "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L20"
click labels "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L25"
click assignees "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L30"
click project-type "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L36"
click project "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L11"
click column "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L49"
click milestone "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L55"
click pinned "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L60"
click close-previous "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L67"
click linked-comments "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L74"
click linked-comments-new-issue-text "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L82"
click linked-comments-previous-issue-text "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L89"
click rotate-assignees "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L96"
click issue-number "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L104"
click previous-issue-number "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L107"
click project-v2-issue-item-id "https://github.com/imjohnbo/issue-bot/blob/main/action.yml#L117"
Loading

Template variables

The issue body is treated as a Handlebars template, with support for template variables:

  • assignees: The array of issue assignees.
  • previousIssueNumber: The previous issue number in the series.

The linked comments (linked-comments-new-issue-text, linked-comments-previous-issue-text) support these variables and:

  • newIssueNumber: The new issue number.

Authentication

Issue Bot requires an API token, customizable with the token input, to authenticate with the GitHub API. The default GITHUB_TOKEN should work for all use cases except project and project-v2-path, when its permissions aren't sufficient. Please use a GitHub App installation access token of a GitHub App with repository/project:read-write/organization/project:read-write scope or personal access token with project scope in these cases.

GitHub Apps are in general pretty cool and offer some nice advantages over personal access tokens, so they're preferred when possible.

GitHub App installation access token:

# ...

# Generate installation token for your GitHub App with...you guessed it, an action
# See https://github.com/tibdex/github-app-token for setup
- name: Generate token
  id: generate_token
  uses: tibdex/github-app-token@v1
  with:
    app_id: ${{ secrets.APP_ID }}
    private_key: ${{ secrets.PRIVATE_KEY }}

# New standup issue generated with a GitHub App!
- name: New standup issue
  uses: imjohnbo/issue-bot@v3
  env:
    TOKEN: ${{ steps.generate_token.outputs.token }} # installation access token as output of previous step
  with:
    title: Standup
    body: |-
      ... standup template ...
    token: ${{ env.TOKEN }}

# ...

Personal access token:

# ...

# New standup issue generated with a personal access token
- name: New standup issue
  uses: imjohnbo/issue-bot@v3
  with:
    title: Standup
    body: |-
      ... standup template ...
    token: ${{ env.PAT }}

# ...

Projects support

Issue Bot currently supports Projects (a.k.a. Projects v2, Projects Beta, and Projects Next) (project-v2-path) and Projects (classic) (project, project-type, column, and milestone). See action.yml for more details about these inputs.

Except when adding an issue to a Projects (classic) repository board, where the built in github.token's permissions suffice, it's recommended to use a GitHub App installation access token or personal access token with the proper scopes.

Support for Projects (classic) will be dropped in a future version.

Contributing

Feel free to open an issue, or better yet, a pull request!

License

MIT

issue-bot's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar iamhughes avatar imjohnbo avatar jblew avatar joyvuu-dave avatar parroty avatar sadikassistivlabs avatar seigel avatar swinton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

issue-bot's Issues

Templates

It would be nice to reference built-in templates for common software lifecycle tasks, e.g. the ones that you can add from the Settings UI:

image

But this functionality doesn't belong in issue-bot. Explore if 3rd party actions exist, if imjohnbo/extract-issue-template-fields should be renamed or extended, or if a new action should be created.

Assign Issue to Project and Milestone

It would be a nice feature if we could assign the new issue to a Project and Milestone by name. A good API may be if the user could specify two new inputs:

project
milestone

creating on my own as auto

Hi,

I m trying to figure out the project and also made a template on my sample project. As I see, the issue-bot creating the issue but
I want to set the issue creator as me :) . Is this possible ?
Thanks

projects not working

Hello,

Are projects working for everyone? I can't seem to make it work.

This is the error I get:

Unexpected input(s) 'project-type', valid inputs are ['title', 'body', 'labels', 'assignees', 'project', 'column', 'milestone', 'pinned', 'close-previous', 'linked-comments', 'rotate-assignees']

And here's my code:

name: Weekly
on:
  workflow_dispatch:
  schedule:
    - cron:  '20 07 * * 1'

jobs:
  create_issue:
    name: Send Newsletter
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - name: Send Newsletter
        uses: imjohnbo/[email protected]
        with:
          assignees: "john"
          labels: "workjohn"
          title: "Send Newsletter"
          body: |
                "You know what to do, Rico!"          
                
          project-type: "user"
          project: "2"  
          column : "This Week"
          pinned: false
          close-previous: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

As you can see, I'm using the v3.0 of the bot, but I still can't get it to work. I'm on a user account and the Project I want to access is the one of my "user level" project (not the repository one).

Feature: issue template

Summary

Accept template: ./path/to/issue-template as an input to generate the issue based on a template instead of a hard coded string.

first time run with close-previous: true

I want to use your Github action to create Issues for some tests after a deployment process. After each release I want to close the old issues.
If there is no issue yet (on the first release), I logically get the error: Couldn't find previous issue with labels.
Would it be possible not to throw an error if there is no issue with these labels yet?

Support Projects Beta?

Hello, this is a really handy action, any chance it could work with the new Projects setup and I could set fields with it? Ideally I'd like to have it also default to the current iteration (if the field is an iteration type).

Add date information in mustache

Hi thanks for the lib! I hope it can generate issues with dates in it. For example, create an issue everyday with name Today's meeting (2022.05.22) etc.

Remove assigned users before an issue automatically closes

I use Issue Bot for creating daily checklists and features and I use the assign feature to notify myself that a new issue has been created and to fill it in etc.

Proposal

I'd love to see this feature implemented or considered using a value like: remove-assignees: true/false
With an option to select which assignees to automatically remove. Similar to the assignees: "user1, user2"

I've added a suggestion as to how this might look in the config.yml.

with:
        assignees: "octocat, monalisa"
        close-previous: true
        remove-closed-issue-assignees: true # whether to remove assignees from a close previous issue
        remove-assignees: "octocat"   # removes specific assignee
        remove-all-assignees: true # if true removes all assignees from an issue before closed

Take over the body of the previous issue

I want to take over the previous Body when creating an issue on a regular basis.

For example, when taking over an unresolved task.

Proposal 1

If use_old_body: true is specified, it will be overwritten with the old Body.

I think you just need to implement it here.

body = Handlebars.compile(body)({ previousIssueNumber, assignees: metadata.assignees });

But not convenient.

Proposal 2

Take over only a specific part.

For example.
take_over_word: "take over"

old issue

# tesk
- [x] aaa
- [x] bbb
- [ ] ccc

#  take over
- [x] hoge
- [x] fuga
- [ ] foo
- [ ] bar

new issue

# tesk
- [ ] aaa
- [ ] bbb
- [ ] ccc

#  take over
- [x] hoge
- [x] fuga
- [ ] foo
- [ ] bar

Template overwrites task.
The location of the specified keyword remains the same.

This is good, but unfortunately I didn't seem to be able to implement it right away.

Template parsing stops on hr/ `-------`

I used a hr, line break (------ in markdown) in my template, and the new issue generated was split and only posted what was above that line break.

My hunch is this is related to the template parser, something like this code?

issue-bot/index.js

Lines 108 to 121 in 0056cb0

if (hasHeader) {
// Get header, which is formatted as YAML key/values
const header = yaml.safeLoad(template.split('---')[1].trim());
core.debug(`header: ${header}`);
metadata = {
assignees: header.assignees || '',
labels: header.labels || '',
title: header.title || ''
};
// remove unnecessary YAML metadata found at the top of issue templates (https://help.github.com/en/github/building-a-strong-community/about-issue-and-pull-request-templates#issue-templates)
template = template.split('---')[2].trim();
}

Thanks for the great action!

Wrong previous issue is closed

In one of my workflows, I have a step looking like that:

      - name: Run tests
        run: ...

      - name: Open issue
        if: failure()
        uses: imjohnbo/issue-bot@v2
        with:
          title: CI Failure
          labels: bug, ci
          pinned: true
          close-previous: true
          template: .github/templates/ci-failure.md

When tests are failing, then issue-bot creates an issue. However, it also closes the last issue with a bug label. Not with a bug AND ci label. Only with a bug label.

I would expect issue-bot to close the last created issue with these two labels.

Difficulty working with projects

Hi folks

I can successfully make issues with this github action; however I can't successfully add them to projects. I have a Github App with the right permissions; but keep seeing errors like:

GraphqlError: Could not resolve to a ProjectV2 with the number 4

or

HttpError: Resource not accessible by integration.

Suggestions?

Convert task to issue

You can see here a goal and a method.
To make it easier to use this method, I'd let GitHub convert a new task to an issue and open a task list. (Otherwise, one has to press the corresponding buttons.)
I'm trying to find out whether this is possible. It might be possible:
a. with this action or another from the GitHub marketplace
b. with an action created by me
c. with a feature created by the GitHub team
What can you and I do to achieve at least this simplification, if not the main goal?

`column` field doesn't seem to be taken into account for `project-v2`

Hi,

I've got something like

- name: issue-bot
      uses: imjohnbo/[email protected]
      env:
        TOKEN: ${{ steps.generate_token.outputs.token }}
      with:
        labels: "maintenance, recurring, patching"
        project-type: "organization"
        project-v2-path: orgs/hello/projects/1
        column: "To Do"
        pinned: false
        close-previous: false
        linked-comments: false
        title: "[recurring] Upgrade to most recent image"
        body: ${{ steps.extract.outputs.body }}
        token: ${{ env.TOKEN }}

The new issue makes it into the project but not into the correct column.

Are you able to confirm this? If so do you think a fix would be possible?

Mirror Issues across repos

Hi, is it possible to mirror any created issues on a public repository to a private repo?
[public issues but private code]

Said issues also need to close when closed on the private repo.

Suggestion: Conditional opening

A suggestion: I only wan't to open an issue, if there is not already an issue with the same title. I'm aware of the close-previous functionality, but i want to preserve history on an existing issue. My usecase is output from trivy.

Adding issue to project is now failing with "Cannot read property 'iterator' of undefined."

Hi,

In our GH action we have a step to automatically add certain issues to one of our GH projects.
See sample config bellow:

- name: issue-bot
      uses: imjohnbo/issue-bot@v3
      with:
        labels: "a, b, c"
        project: 1
        column: "To do"
        pinned: false
        close-previous: false
        linked-comments: false
        title: "[recurring] Example task title"
        body: ${{ steps.extract.outputs.body }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This has been working fine but up to 8 days ago.

I noticed this change was released 11 days ago and I think it's related to the runtime error we get, which I believe for us is occurring here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.