- 🔐 Webhook Validation: HMAC signature verification built-in.
- 🤖 Auth Handling: Auto-refreshing installation tokens via
ghinstallation. - 🧩 GitHub Client: Pre-authenticated
go-githubclient in every context. - 📄 Repo Config: Load
.github/config.ymlwith defaults and inheritance. - 🧙 Setup Wizard: One-click GitHub App registration via manifest flow.
go get github.com/light-cms/probot-goCreate main.go:
package main
import (
"context"
"os"
"github.com/google/go-github/github"
"github.com/light-cms/probot-go"
)
func main() {
app, err := probot.New(probot.Options{
AppID: os.Getenv("APP_ID"),
PrivateKey: os.Getenv("PRIVATE_KEY"),
Secret: os.Getenv("WEBHOOK_SECRET"),
})
if err != nil {
panic(err)
}
app.On("issues.opened", func(ctx *probot.Context) error {
issue := ctx.Issue()
_, _, err := ctx.GitHub().Issues.CreateComment(
context.Background(), issue.Owner, issue.Repo, issue.Number,
&github.IssueComment{Body: github.Ptr("Thanks for opening this issue!")},
)
return err
})
probot.NewServer(probot.ServerOptions{Probot: app}).Start()
}Run it:
go run main.goVisit
http://localhost:3000to register your app via the wizard if no env vars are set.
type Options struct {
AppID string // GitHub App ID
PrivateKey string // PEM contents or path via PRIVATE_KEY_PATH
Secret string // Webhook secret (default: "development")
GithubToken string // Optional: Use PAT instead of App Auth
LogLevel string // trace|debug|info|warn|error (default: info)
Port int // Default: 3000
BaseURL string // For GitHub Enterprise Server
}// Single event
app.On("pull_request.opened", handler)
// Multiple events
app.OnMany([]string{"issues.closed", "pr.closed"}, handler)
// All events
app.OnAny(handler)
// Errors
app.OnError(func(ctx *probot.Context, err error) { ... })ctx.GitHub(): Authenticated*github.Client.ctx.Issue(),ctx.Repo(),ctx.PullRequest(): Parsed structs.ctx.Config("config.yml", defaults): Loads repo config.ctx.Log(): Structured logger (zerolog).
mux := http.NewServeMux()
mux.Handle("/webhooks", app.WebhookMiddleware(http.HandlerFunc(next)))
http.ListenAndServe(":8080", mux)Tests run offline. Use Receive to simulate events:
app.Receive(&github.Event{
Type: github.String("issues"),
Action: github.String("opened"),
// ... payload
})- Fork the repo.
- Run
go test ./...andgofmt -l .. - Submit a PR.