Merge pull request #23 from nektos/issue-22

fix #22: require prefix './' for local actions
This commit is contained in:
Casey Lee 2019-01-25 07:28:02 -08:00 committed by GitHub
commit c2e1188cfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"github.com/nektos/act/common"
log "github.com/sirupsen/logrus"
@ -14,9 +15,10 @@ import (
// imageURL is the directory where a `Dockerfile` should exist
func parseImageLocal(workingDir string, contextDir string) (contextDirOut string, tag string, ok bool) {
if !filepath.IsAbs(contextDir) {
contextDir = filepath.Join(workingDir, contextDir)
if !strings.HasPrefix(contextDir, "./") {
return "", "", false
}
contextDir = filepath.Join(workingDir, contextDir)
if _, err := os.Stat(filepath.Join(contextDir, "Dockerfile")); os.IsNotExist(err) {
log.Debugf("Ignoring missing Dockerfile '%s/Dockerfile'", contextDir)
return "", "", false

View file

@ -43,7 +43,8 @@ func TestParseImageLocal(t *testing.T) {
}{
{"docker://myhost.com/foo/bar", "", "", false},
{"http://google.com:8080", "", "", false},
{"example/action1", "/example/action1", "action1:", true},
{"example/action1", "", "", false},
{"./example/action1", "/example/action1", "action1:", true},
}
revision, _, err := common.FindGitRevision(".")