fix: use github auth token for pulling a repository (#693)

Co-Authored-By: Markus Wolf <markus.wolf@new-work.se>

Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
This commit is contained in:
Björn Brauer 2021-05-19 15:40:28 +02:00 committed by GitHub
parent 29ea8cfc4e
commit 60b9606fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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)