fix 22: require prefix './' for local actions

This commit is contained in:
Casey Lee 2019-01-24 22:17:58 -08:00
parent 320e9b6057
commit ca268132b9
No known key found for this signature in database
GPG key ID: 4CC378651BF9C168
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(".")