-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from LuBingtan/dev
docs: Add probot docs.
- Loading branch information
Showing
6 changed files
with
143 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<p align="center"> | ||
<a href="https://probot.github.io"><img src="docs/robot.svg" width="160" alt="Probot's logo, a cartoon robot" /></a> | ||
</p> | ||
|
||
<h1 align="center">Go-Probot</h1> | ||
|
||
> A framework for building GitHub Apps to automate and improve your workflow, in **Golang**. | ||
> | ||
> Inspired by [Probot](https://github.com/probot/probot). | ||
## Example | ||
|
||
Please check the simplest [example](example/main.go). | ||
|
||
## Features | ||
|
||
- [x] Support building Github App | ||
- [ ] Simple dashboard | ||
- [ ] Support intergration with [Gitlab community edition](https://docs.gitlab.com/ee/install/) | ||
- [ ] Support intergration with [Gerrit](https://www.gerritcodereview.com/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package github_test | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/go-github/v48/github" | ||
"github.com/spf13/pflag" | ||
|
||
"github.com/airconduct/kuilei/pkg/probot" | ||
probotgh "github.com/airconduct/kuilei/pkg/probot/github" | ||
) | ||
|
||
func main() { | ||
app := probot.NewGithubAPP() | ||
app.AddFlags(pflag.CommandLine) | ||
pflag.Parse() | ||
|
||
// Add a handler for events "issue_comment.created" | ||
app.On(probotgh.Event.IssueComment_created).WithHandler(probotgh.IssueCommentHandler(func(ctx probotgh.IssueCommentContext) { | ||
payload := ctx.Payload() | ||
ctx.Logger().Info("Get IssueComment event", "payload", payload) | ||
owner := payload.Repo.Owner.GetLogin() | ||
repo := payload.Repo.GetName() | ||
issueNumber := *payload.Issue.Number | ||
// If any error happen, the error message will be logged and sent as response | ||
ctx.Must(ctx.Client().Issues.CreateComment(ctx, owner, repo, issueNumber, &github.IssueComment{ | ||
Body: github.String("Reply to this comment."), | ||
})) | ||
})) | ||
|
||
// Add a handler for multiple events | ||
app.On( | ||
probotgh.Event.PullRequest_opened, // pull_request.opened | ||
probotgh.Event.PullRequest_edited, // pull_request.edited | ||
probotgh.Event.PullRequest_synchronize, // pull_request.synchronize | ||
probotgh.Event.PullRequest_labeled, // pull_request.labeled | ||
probotgh.Event.PullRequest_assigned, // pull_request.assigned | ||
).WithHandler(probotgh.PullRequestHandler(func(ctx probotgh.PullRequestContext) { | ||
payload := ctx.Payload() | ||
ctx.Logger().Info("Do something", "action", payload.GetAction(), "PullRequest labels", payload.PullRequest.Labels) | ||
})) | ||
|
||
if err := app.Run(context.Background()); err != nil { | ||
panic(err) | ||
} | ||
} |