Move privatekey to a env variable

This commit is contained in:
Sebastian Cabrera 2023-08-28 21:40:17 -04:00
parent 9db39a481d
commit 03642cfd73
2 changed files with 10 additions and 2 deletions

1
bot/.gitignore vendored
View file

@ -1 +0,0 @@
*.pem

View file

@ -7,12 +7,14 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
"log" "log"
"net/http" "net/http"
"os"
"strconv" "strconv"
"strings" "strings"
) )
// Wrap the shared transport for use with the integration ID and authenticating with installation ID. // Wrap the shared transport for use with the integration ID and authenticating with installation ID.
var itr, _ = ghinstallation.NewKeyFromFile(http.DefaultTransport, 381312, 41105280, "theopenestsource.2023-08-26.private-key.pem") var privateKey = os.Getenv("privateKey")
var itr, _ = ghinstallation.NewKeyFromFile(http.DefaultTransport, 381312, 41105280, privateKey)
// Use installation transport with client. // Use installation transport with client.
var client = github.NewClient(&http.Client{Transport: itr}) var client = github.NewClient(&http.Client{Transport: itr})
@ -20,6 +22,13 @@ var ctx = context.Background()
func initGitHubClient() { func initGitHubClient() {
log.Println("Initializing......") log.Println("Initializing......")
if privateKey != "" {
log.Println(privateKey)
} else {
log.Println("Private key not found!")
os.Exit(0)
}
} }
func listenForWebhook() { func listenForWebhook() {