{{announcement.body}}
{{announcement.title}}

Automate Task Creation With the TODO Bot

DZone 's Guide to

Automate Task Creation With the TODO Bot

Do you litter your code with "TODO" keywords so you'll remember to come back to them? With this handy GitHub bot, you'll never have to remember again. Maybe.

· DevOps Zone ·
Free Resource

Like many of you (I hope), I tend to litter my code and articles with TODOs, while in the flow of coding or writing. I intend to return to and act on them at some point, but like many good intentions, and especially tasks, finding them again is one part of the problem. 

I like to have tasks assigned to me in issue trackers so I can more easily find them, and adding todo's in the middle of code or documents (I’m looking at you Google Docs!) doesn’t surface them enough for my liking.

A few months ago, I came across the wonderful todo GitHub app from Jason Etco, which he built with Probot. The app parses your code for TODOs or other keywords and adds them as GitHub issues with preconfigured assignees, labels, and more.

You might also like: What Is DevOps? The Beginner’s Guide

Install and Configure

Add todo app to GitHub repositories

Install the app in your repo by visiting the app page and clicking the Configure button. Because of GitHub permissions, you may not be able to install the app in all the repositories you want to, or you may need to ask for permission to an organization administrator. If you do have the correct permissions, you can install the app in all your repositories, or particular repositories. 

The todo app has sensible defaults, assigning a todo to the committer, so it works as soon as you install it, but you probably want to dive in to tweak settings for individual repositories, especially those you collaborate on with others.

Before we push any code and create issues, let’s change a few settings.

As with other GitHub apps, you need to create a .github folder at the top level of your repo, and inside that, a config.yml file. Here are the settings you can change, all of which are child keys of the todo key:

todo:
    keyword: ["@todo", "TODO", "TODO:"]
    autoAssign: true
    bodyKeyword: ["@body", "BODY"]
    blobLines: 10
    caseSensitive: false
    label: ["todo", "bot"]
    reopenClosed: true

Most of the settings are reasonably self-explanatory, but you can find a full reference in the project read me.

The settings above configure the todo app to do the following:

  • Look for three keywords in your code
  • Automatically assign the issues to whoever pushed the change; you can add an array of manual user names instead
  • Add any text to the issue body equal to the value(s) of bodyKeyword (found in your code)
  • Includes the ten following lines of code in the issue body
  • Adds two labels
  • Reopens any matching issues already closed

Push Your Productivity

You can see the todos in my code on this search page, and to trigger the bot, you need to push to any branch. If you push to a branch that already has a PR in progress, the app adds it as a comment instead of a new issue. Helpfully, the app also tries it’s best to close issues once the matching text is removed as part of a PR.

And voila! Issues automatically created every time you add them. Now all you have to do next is actually work on the issues, but that’s a whole other story.

Further Reading

9 Features That Make a Great Task Management Tool

Five Tasks IT Should Be Having Automated

Topics:
automation ,bot ,development ,github ,project management ,task automation

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}