mirror of
https://github.com/zoriya/cish.git
synced 2026-08-16 02:44:46 +00:00
config with viper and env var
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package github
|
||||
|
||||
func CreateRepositoryAccessToken(repoName string, installationID int64) string {
|
||||
return ""
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user