mirror of
https://github.com/kennethreitz/herald.git
synced 2026-06-05 23:00:19 +00:00
writing github issues!
This commit is contained in:
Generated
+44
-13
@@ -110,6 +110,24 @@
|
||||
revision = "32e4c1e6bc4e7d0d8451aa6b75200d19e37a536a"
|
||||
version = "v1.32.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = ["proto"]
|
||||
revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/google/go-github"
|
||||
packages = ["github"]
|
||||
revision = "218ecc238cf77bbaa2e16a54cada252ec87e7d6e"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/google/go-querystring"
|
||||
packages = ["query"]
|
||||
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-cleanhttp"
|
||||
@@ -242,12 +260,6 @@
|
||||
revision = "cb6bfca970f6908083f26f39a79009d608efd5cd"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mailgun/mailgun-go"
|
||||
packages = ["."]
|
||||
revision = "a4002e2df2e8ca2da6a6fbb4a72871b504e49f50"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mattn/go-colorable"
|
||||
packages = ["."]
|
||||
@@ -284,12 +296,6 @@
|
||||
packages = ["."]
|
||||
revision = "a61a99592b77c9ba629d254a693acffaeb4b7e28"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/russross/blackfriday"
|
||||
packages = ["."]
|
||||
@@ -344,17 +350,42 @@
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"context",
|
||||
"context/ctxhttp",
|
||||
"html",
|
||||
"html/atom"
|
||||
]
|
||||
revision = "d866cfc389cec985d6fda2859936a575a55a3ab6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/oauth2"
|
||||
packages = [
|
||||
".",
|
||||
"internal"
|
||||
]
|
||||
revision = "30785a2c434e431ef7c507b54617d6a951d5f2b4"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix"]
|
||||
revision = "b8f5ef32195cae6470b728e8ca677f0dbed1a004"
|
||||
|
||||
[[projects]]
|
||||
name = "google.golang.org/appengine"
|
||||
packages = [
|
||||
"internal",
|
||||
"internal/base",
|
||||
"internal/datastore",
|
||||
"internal/log",
|
||||
"internal/remote_api",
|
||||
"internal/urlfetch",
|
||||
"urlfetch"
|
||||
]
|
||||
revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "v2"
|
||||
name = "gopkg.in/yaml.v2"
|
||||
@@ -364,6 +395,6 @@
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "6e5a8becd6ad2bd1d88a01d4d74fe47f2ae22e490f78d3255b55ebd096004a39"
|
||||
inputs-digest = "02581f9c20f3fa1daf2dacb89e71feb62298f452a06db6d3757799727700c73f"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
||||
+12
@@ -41,3 +41,15 @@
|
||||
[[constraint]]
|
||||
name = "github.com/urfave/cli"
|
||||
version = "1.20.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/githubql"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/google/go-github"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/oauth2"
|
||||
|
||||
+48
-28
@@ -1,31 +1,49 @@
|
||||
package main
|
||||
|
||||
import "github.com/heroku/herald"
|
||||
import "github.com/fatih/color"
|
||||
import "github.com/mailgun/mailgun-go"
|
||||
import "time"
|
||||
import "log"
|
||||
import "fmt"
|
||||
import "os"
|
||||
import (
|
||||
"github.com/heroku/herald";
|
||||
"github.com/fatih/color";
|
||||
"github.com/google/go-github/github";
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
import (
|
||||
"time";
|
||||
"log";
|
||||
"fmt";
|
||||
"os";
|
||||
"context"
|
||||
)
|
||||
|
||||
var MAILGUN_DOMAIN = os.Getenv("MAILGUN_DOMAIN")
|
||||
var MAILGUN_API_KEY = os.Getenv("MAILGUN_API_KEY")
|
||||
var MAILGUN_PUBLIC_KEY = os.Getenv("MAILGUN_PUBLIC_KEY")
|
||||
func open_issue(bp herald.Buildpack, target string) {
|
||||
ctx := context.Background()
|
||||
ts := oauth2.StaticTokenSource(
|
||||
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
|
||||
)
|
||||
tc := oauth2.NewClient(ctx, ts)
|
||||
|
||||
client := github.NewClient(tc)
|
||||
|
||||
func send_email(to string, version string) {
|
||||
|
||||
mg := mailgun.NewMailgun(MAILGUN_DOMAIN, MAILGUN_API_KEY, MAILGUN_PUBLIC_KEY)
|
||||
message := mg.NewMessage(
|
||||
to,
|
||||
"Fancy subject!",
|
||||
"Hello from Mailgun Go!",
|
||||
"me@sandbox13d17507cb14496a9d97fe500600ac68.mailgun.org")
|
||||
resp, id, err := mg.Send(message)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("ID: %s Resp: %s\n", id, resp)
|
||||
title := fmt.Sprintf("New release (%s) available! (Herald System)", target)
|
||||
body := fmt.Sprintf("This issue created programmatically and automatically by Heroku, on behalf of %s, the owner of the %s buildpack.", bp.Owner, bp.Name)
|
||||
|
||||
newIssue := github.IssueRequest{
|
||||
Title: &title,
|
||||
Body: &body,
|
||||
// Labels: ["New Build Target"],
|
||||
Assignee: &bp.Owner,
|
||||
}
|
||||
// list all repositories for the authenticated user
|
||||
bp_name := fmt.Sprintf("heroku-buildpack-%s", bp.Name)
|
||||
fmt.Println(bp_name)
|
||||
|
||||
issue, _, err := client.Issues.Create(ctx, "heroku", bp_name, &newIssue)
|
||||
if err != nil {
|
||||
// do something
|
||||
}
|
||||
// _ = issue
|
||||
fmt.Println(issue)
|
||||
|
||||
fmt.Println(fmt.Sprintf("New issue created on %s buildpack on GitHub.", bp.Name))
|
||||
}
|
||||
|
||||
|
||||
@@ -78,11 +96,13 @@ func main() {
|
||||
// Store the results in Redis.
|
||||
result, err := redis.Connection.Do("SETNX", key, value)
|
||||
|
||||
// The insert was successful (e.g. it didn't exist already)
|
||||
if result.(int64) != int64(0) {
|
||||
// TODO: Send a notification to the buildpack owner.
|
||||
fmt.Println("Notifying %s about %s.", blue(bp.Owner), red(key))
|
||||
// send_email(bp.Owner, key)
|
||||
// The insert was successful (e.g. it didn't exist already)
|
||||
if result.(int64) != int64(0) {
|
||||
// TODO: Send a notification to the buildpack owner.
|
||||
fmt.Println("Notifying", blue(bp.Owner), "about", red(key), ".")
|
||||
|
||||
// Open an issue on GitHub (work in progress).
|
||||
open_issue(bp, key)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -23,7 +23,7 @@ type OwnedBuildpack struct {
|
||||
}
|
||||
|
||||
var BUILDPACKS = []OwnedBuildpack{
|
||||
{Name: "python", Owner: "kreitz@salesforce.com"},
|
||||
{Name: "python", Owner: "kennethreitz"},
|
||||
{Name: "php", Owner: "kreitz@salesforce.com"},
|
||||
{Name: "nodejs", Owner: "kreitz@salesforce.com"},
|
||||
{Name: "ruby", Owner: "kreitz@salesforce.com"},
|
||||
|
||||
Reference in New Issue
Block a user