DEV Community

Cover image for Creating a GitHub stale repositories cleanup bot with Boomerang Flow
Tyson Lawrie
Tyson Lawrie

Posted on

Creating a GitHub stale repositories cleanup bot with Boomerang Flow

Why Boomerang Flow?

Boomerang Flow is a no-code event-driven cloud native workflow automation tool and is an open-source project.

There are a number of tools that you can use to create a GitHub bot; GitHub Actions, Netlify, Heroku, or any functions hosting cloud, with various skill levels required.

The following will give you a view on doing the same with no-code automation.

Why a repositories bot?

This particular bot is useful to identify if new repositories are being created and you want to make sure to keep a clean GitHub Organization. Its possible that repositories get created for testing purposes and forgotten about, or are created and now need to be managed with issue templates or a license.

Creating the Workflow

Creating the Workflow

The default landing page is the Workflows screen and in your space will be the ability to create a new workflow.

Wiring together the bot

Wiring together the bot

On the Workflow Editor screen you can drag and drop a number of tasks from the palette providing a great end user experience. For advanced management these tasks are Tekton defined YAML and can be managed via the Task Manager.

Find Repositories in Org

Drag on the Find Repositories in Org Task and add the required specifics.

Custom Task Name: Find Repositories.
This will be used later on to get the result parameters.

Parameter Value
URL https://github.com/api/v3
Token You can get this value on github.com from your profile under Settings > Developer settings > Personal Access Tokens.
Org The org you want to scan, in this demo I chose the boomerang-io org
Visibility The types of repositories you want returned. Default: All
Repositories to Skip This is a newline delimited list of repositories to ignore based on repository name
Number of Repositories to Retrieve Helpful to retrieve more or less based on the GitHub API paging.

Send Simple Slack Message

Drag on the Send Simple Slack Message Task and add the required specifics.

We make use of the prior tasks result parameters to output the repositories of note.

Parameter Value
Webhook URL You create this in Slack App for your workspace as an Incoming Webhook and will be similar to https://hooks.slack.com/services/<id>/<id>/<id>
Channel This can be a channel or direct message
Icon I usually go for a bot or Github logo
Username Boomerang GitHub Bot
Message This is a weekly reminder announcement from your friendly GitHub Bot\n\nThe following repositories are currently in the Boomerang org and need to be cleaned up:\n$(task.Find Repositories.results.repositoriesPrettyPrint)

Wire the Tasks together

Drag and drop the lines between the tasks. You can make use of the Task state as well by changing it to only proceed on success.

Find out more information about Link and Tasks states.

Configure Schedule Trigger

Configure Schedule Trigger

We want this to run on a weekly or monthly schedule. On the Configure tab under Triggers, enable the Scheduler and then click Change Schedule.

In the basic view you can set a weekly schedule or you can switch to the advanced view and set any cron based schedule.

The Activity

Screen Shot 2021-06-01 at 11.42.10 AM

Boomerang Flow provides an activity view where you can see whats running, dynamically tail logs, and view a Tasks Result Parameters.

Screen Shot 2021-06-01 at 11.42.20 AM

Result Parameters are important in this Workflow as it is how we passed information from the repositories listing Task that connected to GitHub, to the Slack messaging Task.

The Result

The slack message

And as you can see, the workflow resulted in a message post to a Slack channel. This is a really easy, no-code way of creating a bot.

What did we achieve

  • A no-code workflow
  • No configuration of setting up a function running in a cloud
  • No YAML!
  • Easy to use interface for providing information
  • A bot that can keep on running and be refined with a filterable list.

Future Steps

If you are confident that the bot is now finding the correct repositories, you can implement a repository deletion mechanism or raise a GitHub issue to close the repository.

Show your support

Show your support if this helped you:

Top comments (0)