Skip to content

Instantly share code, notes, and snippets.

@sridharavinash
Last active August 8, 2018 08:37
Show Gist options
  • Save sridharavinash/4515e3bedd79d5fb4f2ffc6ab8bf704f to your computer and use it in GitHub Desktop.
Save sridharavinash/4515e3bedd79d5fb4f2ffc6ab8bf704f to your computer and use it in GitHub Desktop.
Check Run API example using an installed GitHub App
package main
import (
"context"
"fmt"
"net/http"
"github.com/bradleyfalzon/ghinstallation"
"github.com/google/go-github/github"
)
func main() {
fmt.Println("Creating a check run...")
ctx := context.Background()
tr := http.DefaultTransport
itr, err := ghinstallation.NewKeyFromFile(tr, <app_id>, <integration_id>, "key.pem")
if err != nil {
panic(err)
}
client := github.NewClient(&http.Client{Transport: itr})
opts := github.CreateCheckRunOptions{
Name: "Mighty test check run",
HeadBranch: <your_branch_name>,
HeadSHA: <SHA_commit>,
Status: github.String("in_progress"),
}
ckrun, resp, err := client.Checks.CreateCheckRun(ctx, <owner>, <repo>, opts)
if err != nil {
panic(err)
}
fmt.Printf("%v\n%v\n", resp, ckrun)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment