|
|
|
|
@@ -173,6 +173,7 @@ func (sc *StepContext) setupShellCommand() common.Executor {
|
|
|
|
|
if step.WorkingDirectory == "" {
|
|
|
|
|
step.WorkingDirectory = rc.Run.Workflow.Defaults.Run.WorkingDirectory
|
|
|
|
|
}
|
|
|
|
|
step.WorkingDirectory = rc.ExprEval.Interpolate(step.WorkingDirectory)
|
|
|
|
|
if step.WorkingDirectory != "" {
|
|
|
|
|
_, err = script.WriteString(fmt.Sprintf("cd %s\n", step.WorkingDirectory))
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -181,6 +182,7 @@ func (sc *StepContext) setupShellCommand() common.Executor {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run := rc.ExprEval.Interpolate(step.Run)
|
|
|
|
|
step.Shell = rc.ExprEval.Interpolate(step.Shell)
|
|
|
|
|
|
|
|
|
|
if _, err = script.WriteString(run); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
@@ -381,15 +383,13 @@ func getOsSafeRelativePath(s, prefix string) string {
|
|
|
|
|
func (sc *StepContext) getContainerActionPaths(step *model.Step, actionDir string, rc *RunContext) (string, string) {
|
|
|
|
|
actionName := ""
|
|
|
|
|
containerActionDir := "."
|
|
|
|
|
if !rc.Config.BindWorkdir && step.Type() != model.StepTypeUsesActionRemote {
|
|
|
|
|
if step.Type() != model.StepTypeUsesActionRemote {
|
|
|
|
|
actionName = getOsSafeRelativePath(actionDir, rc.Config.Workdir)
|
|
|
|
|
containerActionDir = ActPath + "/actions/" + actionName
|
|
|
|
|
containerActionDir = rc.Config.ContainerWorkdir() + "/" + actionName
|
|
|
|
|
actionName = "./" + actionName
|
|
|
|
|
} else if step.Type() == model.StepTypeUsesActionRemote {
|
|
|
|
|
actionName = getOsSafeRelativePath(actionDir, rc.ActionCacheDir())
|
|
|
|
|
containerActionDir = ActPath + "/actions/" + actionName
|
|
|
|
|
} else if step.Type() == model.StepTypeUsesActionLocal {
|
|
|
|
|
actionName = getOsSafeRelativePath(actionDir, rc.Config.Workdir)
|
|
|
|
|
containerActionDir = ActPath + "/actions/" + actionName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if actionName == "" {
|
|
|
|
|
@@ -422,11 +422,9 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe
|
|
|
|
|
log.Debugf("type=%v actionDir=%s actionPath=%s Workdir=%s ActionCacheDir=%s actionName=%s containerActionDir=%s", step.Type(), actionDir, actionPath, rc.Config.Workdir, rc.ActionCacheDir(), actionName, containerActionDir)
|
|
|
|
|
|
|
|
|
|
maybeCopyToActionDir := func() error {
|
|
|
|
|
sc.Env["GITHUB_ACTION_PATH"] = containerActionDir
|
|
|
|
|
if step.Type() != model.StepTypeUsesActionRemote {
|
|
|
|
|
// If the workdir is bound to our repository then we don't need to copy the file
|
|
|
|
|
if rc.Config.BindWorkdir {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
err := removeGitIgnore(actionDir)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -570,28 +568,29 @@ func (sc *StepContext) execAsComposite(ctx context.Context, step *model.Step, _
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if stepClone.Env == nil {
|
|
|
|
|
stepClone.Env = make(map[string]string)
|
|
|
|
|
}
|
|
|
|
|
actionPath := filepath.Join(containerActionDir, actionName)
|
|
|
|
|
|
|
|
|
|
env := stepClone.Environment()
|
|
|
|
|
env["GITHUB_ACTION_PATH"] = actionPath
|
|
|
|
|
stepClone.Run = strings.ReplaceAll(stepClone.Run, "${{ github.action_path }}", actionPath)
|
|
|
|
|
|
|
|
|
|
stepContext := StepContext{
|
|
|
|
|
RunContext: rcClone,
|
|
|
|
|
Step: &stepClone,
|
|
|
|
|
Step: step,
|
|
|
|
|
Env: mergeMaps(sc.Env, env),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interpolate the outer inputs into the composite step with items
|
|
|
|
|
exprEval := sc.NewExpressionEvaluator()
|
|
|
|
|
for k, v := range stepContext.Step.With {
|
|
|
|
|
if strings.Contains(v, "inputs") {
|
|
|
|
|
stepContext.Step.With[k] = exprEval.Interpolate(v)
|
|
|
|
|
}
|
|
|
|
|
// Required to set github.action_path
|
|
|
|
|
if rcClone.Config.Env == nil {
|
|
|
|
|
// Workaround to get test working
|
|
|
|
|
rcClone.Config.Env = make(map[string]string)
|
|
|
|
|
}
|
|
|
|
|
rcClone.Config.Env["GITHUB_ACTION_PATH"] = sc.Env["GITHUB_ACTION_PATH"]
|
|
|
|
|
ev := stepContext.NewExpressionEvaluator()
|
|
|
|
|
// Required to interpolate inputs and github.action_path into the env map
|
|
|
|
|
stepContext.interpolateEnv(ev)
|
|
|
|
|
// Required to interpolate inputs, env and github.action_path into run steps
|
|
|
|
|
ev = stepContext.NewExpressionEvaluator()
|
|
|
|
|
stepClone.Run = ev.Interpolate(stepClone.Run)
|
|
|
|
|
stepClone.Shell = ev.Interpolate(stepClone.Shell)
|
|
|
|
|
stepClone.WorkingDirectory = ev.Interpolate(stepClone.WorkingDirectory)
|
|
|
|
|
|
|
|
|
|
stepContext.Step = &stepClone
|
|
|
|
|
|
|
|
|
|
executors = append(executors, stepContext.Executor())
|
|
|
|
|
}
|
|
|
|
|
|