From 60b9606fc687549c7f55343a4d52ff3f2c32cf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Brauer?= Date: Wed, 19 May 2021 15:40:28 +0200 Subject: [PATCH] fix: use github auth token for pulling a repository (#693) Co-Authored-By: Markus Wolf Co-authored-by: Markus Wolf --- pkg/common/git.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/common/git.go b/pkg/common/git.go index 233a6b7..d563ff1 100644 --- a/pkg/common/git.go +++ b/pkg/common/git.go @@ -361,9 +361,17 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) Executor { } } - if err = w.Pull(&git.PullOptions{ + pullOptions := git.PullOptions{ Force: true, - }); err != nil && err.Error() != "already up-to-date" { + } + if input.Token != "" { + pullOptions.Auth = &http.BasicAuth{ + Username: "token", + Password: input.Token, + } + } + + if err = w.Pull(&pullOptions); err != nil && err.Error() != "already up-to-date" { logger.Debugf("Unable to pull %s: %v", refName, err) } logger.Debugf("Cloned %s to %s", input.URL, input.Dir)