Creating a GitHub stale repositories cleanup bot with Boomerang Flow
Tags: automation, github, workflow, bots
Published: 2021-06-01 01:53:02

## Why Boomerang Flow?

[Boomerang Flow](https://useboomerang.io/) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzqf9c26dp9auehwjjh1.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1bg6qloqwwc34f0vx50c.png)

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](https://www.useboomerang.io/docs/boomerang-flow/3.2.0/how-to-guide/workflow-editor/#links).

## Configure Schedule Trigger

![Configure Schedule Trigger](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sgb01xs6r172xw80vjkd.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6psrfjhr4rsquthzkhg.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s7mg038secti5xfxr77g.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dd5kwn3s5tvlc5wotda6.png)

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:

- [⭐️ the GitHub repository](https://github.com/boomerang-io/flow.client.web)
- [💬 Follow us on Twitter](https://twitter.com/useboomerangio)
- [Install the project](https://www.useboomerang.io/docs/boomerang-flow/installing/installing) on your own Kubernetes cluster
- 🙏 [Join us and help contribute](https://github.com/boomerang-io/roadmap)