21
Creating a GitHub stale repositories cleanup bot with Boomerang Flow
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.
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.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--P8gtdOmo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/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.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--GK13asd_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/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.
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. |
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) |
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://res.cloudinary.com/practicaldev/image/fetch/s--3pU8ubAp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/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.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--j53vF1Uu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/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.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--uMtlvtU---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/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.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--5PMGkUs2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/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.
- 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.
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 if this helped you:
- ⭐️ the GitHub repository
- 💬 Follow us on Twitter
- Install the project on your own Kubernetes cluster
- 🙏 Join us and help contribute
21