Categorygithub.com/sourcegraph/maintainerbot
modulepackage
0.0.0-20200204165715-d8ca063a7c64
Repository: https://github.com/sourcegraph/maintainerbot.git
Documentation: pkg.go.dev

# README

maintainerbot

Maintainerbot is designed to make it easy to create custom bots for interacting with Github repositories. The core of Maintainerbot is maintner, a Go program that creates an in-memory representation of your Github repository. Removing the Github API (and the need to handle rate limits, and paging) is a great way to make creating bots easy.

(maintner and gopherbot are written by the Go Authors, and available from the golang.org/x/build package.)

Usage

Here's a bot that can check whether users have signed the CLA, against a list of usernames stored in a spreadsheet.

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
defer cancel()

token := os.Getenv("GITHUB_TOKEN")
ghc := maintainerbot.NewGitHubClient(token, 0)
bot := maintainerbot.New("rails", "rails", token)
spreadsheetURL := "https://docs.google.com/spreadsheets/d/<key>/export?format=csv&sheet=0"
cla := tasks.NewCLAChecker(ghc, "http://example.com/sign-cla", tasks.NewSpreadsheetFetcher(spreadsheetURL))
cla.StartFetch(ctx)
bot.RegisterTask(cla)
bot.Run(ctx)

Other task types are available in the tasks package.

Installation

go get -u github.com/sourcegraph/maintainerbot

More Docs/Examples

Check out the godoc for more comprehensive documentation. A running example (the one used by Sourcegraph, as of October 2018) can be found in the examples directory.

# Packages

The sgbot command runs automated tasks against the Sourcegraph Github repo.
Package tasks contains a list of tasks that can be run with the bot.

# Functions

New creates a new Bot.
NewGitHubClient creates a new GitHub client for the given token.

# Structs

No description provided by the author

# Interfaces

Task is any periodic task that you would like to run on the repository.