config with viper and env var

This commit is contained in:
GitBluub
2025-08-24 00:04:05 +02:00
parent b23c0cd5b0
commit 3df41aaa11
6 changed files with 226 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
package github
func CreateRepositoryAccessToken(repoName string, installationID int64) string {
return ""
}
+32
View File
@@ -0,0 +1,32 @@
package github
import (
"fmt"
"os"
"github.com/go-git/go-git/v6"
"github.com/go-git/go-git/v6/plumbing/transport/http"
)
type Repository struct {
Name string // Full repo name like zoriya/cish
CloneURL string
InstallationID int64
}
func (r *Repository) Clone(ref string) error {
installToken := ""
_, err := git.PlainClone(fmt.Sprintf("/tmp/%s", r.Name), &git.CloneOptions{
URL: r.CloneURL,
Auth: &http.BasicAuth{
Username: "cish", // yes, this can be anything except an empty string
Password: installToken,
},
Progress: os.Stdout,
})
if err != nil {
return err
}
return nil
}
+7 -1
View File
@@ -15,8 +15,14 @@ func HandleEvent(event *github.WebhookEvent) error {
case github.PushEvent:
payload := event.Payload.(*github.PushPayload)
log.Printf("Push to %s by %s",
payload.Repository.FullName,
payload.Repository.ContentsURL,
payload.PusherPerson.Name)
// repo := Repository{
// Name: payload.Repository.FullName,
// CloneURL: payload.Repository.CloneURL,
// InstallationID: payload.Installation.ID,
// }
// getJobsFromRepository()
case github.PullRequestEvent:
payload := event.Payload.(*github.PullRequestPayload)