Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit fa7d6ce

Browse files
authored
Merge pull request #15 from docker/login-before-build
Login before build on build-push
2 parents 776ef5a + 5ebd304 commit fa7d6ce

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cmd/build_push.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ import (
88
)
99

1010
func buildPush(cmd command.Runner) error {
11+
registry := options.GetRegistry()
12+
login, err := options.GetLoginOptions()
13+
if err != nil {
14+
return err
15+
}
16+
if login.Username != "" && login.Password != "" {
17+
if err := command.RunLogin(cmd, login, registry); err != nil {
18+
return err
19+
}
20+
}
21+
1122
github, err := options.GetGitHubOptions()
1223
if err != nil {
1324
return err
1425
}
1526

16-
registry := options.GetRegistry()
1727
tags, err := options.GetTags(registry, github)
1828
if err != nil {
1929
return err
@@ -30,16 +40,6 @@ func buildPush(cmd command.Runner) error {
3040
if shouldPush, err := options.ShouldPush(); err != nil {
3141
return err
3242
} else if shouldPush {
33-
login, err := options.GetLoginOptions()
34-
if err != nil {
35-
return err
36-
}
37-
if login.Username != "" && login.Password != "" {
38-
if err := command.RunLogin(cmd, login, registry); err != nil {
39-
return err
40-
}
41-
}
42-
4343
return command.RunPush(cmd, tags)
4444
}
4545

0 commit comments

Comments
 (0)