fix #110 - support path in action (#111)

This commit is contained in:
Casey Lee 2020-02-27 14:17:01 -08:00 committed by GitHub
parent 21e2bb8657
commit 6e1da1a70d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View file

@ -53,8 +53,8 @@ func (sc *StepContext) Executor() common.Executor {
actionDir := filepath.Join(rc.Config.Workdir, step.Uses)
return common.NewPipelineExecutor(
sc.setupEnv(),
sc.setupAction(actionDir),
sc.runAction(actionDir),
sc.setupAction(actionDir, ""),
sc.runAction(actionDir, ""),
)
case model.StepTypeUsesActionRemote:
remoteAction := newRemoteAction(step.Uses)
@ -73,8 +73,8 @@ func (sc *StepContext) Executor() common.Executor {
Dir: actionDir,
}),
sc.setupEnv(),
sc.setupAction(actionDir),
sc.runAction(actionDir),
sc.setupAction(actionDir, remoteAction.Path),
sc.runAction(actionDir, remoteAction.Path),
)
}
@ -206,11 +206,11 @@ func (sc *StepContext) runUsesContainer() common.Executor {
}
}
func (sc *StepContext) setupAction(actionDir string) common.Executor {
func (sc *StepContext) setupAction(actionDir string, actionPath string) common.Executor {
return func(ctx context.Context) error {
f, err := os.Open(filepath.Join(actionDir, "action.yml"))
f, err := os.Open(filepath.Join(actionDir, actionPath, "action.yml"))
if os.IsNotExist(err) {
f, err = os.Open(filepath.Join(actionDir, "action.yaml"))
f, err = os.Open(filepath.Join(actionDir, actionPath, "action.yaml"))
if err != nil {
return err
}
@ -224,7 +224,7 @@ func (sc *StepContext) setupAction(actionDir string) common.Executor {
}
}
func (sc *StepContext) runAction(actionDir string) common.Executor {
func (sc *StepContext) runAction(actionDir string, actionPath string) common.Executor {
rc := sc.RunContext
step := sc.Step
return func(ctx context.Context) error {
@ -258,7 +258,7 @@ func (sc *StepContext) runAction(actionDir string) common.Executor {
return err
}
}
return rc.execJobContainer([]string{"node", fmt.Sprintf("%s/%s/%s", containerActionDir, actionName, action.Runs.Main)}, sc.Env)(ctx)
return rc.execJobContainer([]string{"node", filepath.Join(containerActionDir, actionName, actionPath, action.Runs.Main)}, sc.Env)(ctx)
case model.ActionRunsUsingDocker:
var prepImage common.Executor
var image string
@ -267,7 +267,7 @@ func (sc *StepContext) runAction(actionDir string) common.Executor {
} else {
image = fmt.Sprintf("%s:%s", regexp.MustCompile("[^a-zA-Z0-9]").ReplaceAllString(actionName, "-"), "latest")
image = fmt.Sprintf("act-%s", strings.TrimLeft(image, "-"))
contextDir := filepath.Join(actionDir, action.Runs.Main)
contextDir := filepath.Join(actionDir, actionPath, action.Runs.Main)
prepImage = container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{
ContextDir: contextDir,
ImageTag: image,

View file

@ -8,3 +8,5 @@ jobs:
- uses: actions/hello-world-javascript-action@master
with:
who-to-greet: 'Mona the Octocat'
- uses: cloudposse/actions/github/slash-command-dispatch@0.14.0