fix: localcheckout mock (#1198)
* Update run_context.go * Update step_action_remote.go * Update step_action_remote.go * [no ci] eval path * Update step_action_remote.go * Update step_action_remote.go * Update step_action_remote.go Co-authored-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
parent
7105919f0c
commit
c3fb6864e8
|
@ -173,13 +173,6 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
})
|
})
|
||||||
|
|
||||||
var copyWorkspace bool
|
|
||||||
var copyToPath string
|
|
||||||
if !rc.Config.BindWorkdir {
|
|
||||||
copyToPath, copyWorkspace = rc.localCheckoutPath(ctx)
|
|
||||||
copyToPath = filepath.Join(rc.Config.ContainerWorkdir(), copyToPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
return common.NewPipelineExecutor(
|
return common.NewPipelineExecutor(
|
||||||
rc.JobContainer.Pull(rc.Config.ForcePull),
|
rc.JobContainer.Pull(rc.Config.ForcePull),
|
||||||
rc.stopJobContainer(),
|
rc.stopJobContainer(),
|
||||||
|
@ -188,7 +181,6 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
rc.JobContainer.UpdateFromImageEnv(&rc.Env),
|
rc.JobContainer.UpdateFromImageEnv(&rc.Env),
|
||||||
rc.JobContainer.UpdateFromEnv("/etc/environment", &rc.Env),
|
rc.JobContainer.UpdateFromEnv("/etc/environment", &rc.Env),
|
||||||
rc.JobContainer.Exec([]string{"mkdir", "-m", "0777", "-p", ActPath}, rc.Env, "root", ""),
|
rc.JobContainer.Exec([]string{"mkdir", "-m", "0777", "-p", ActPath}, rc.Env, "root", ""),
|
||||||
rc.JobContainer.CopyDir(copyToPath, rc.Config.Workdir+string(filepath.Separator)+".", rc.Config.UseGitIgnore).IfBool(copyWorkspace),
|
|
||||||
rc.JobContainer.Copy(ActPath+"/", &container.FileEntry{
|
rc.JobContainer.Copy(ActPath+"/", &container.FileEntry{
|
||||||
Name: "workflow/event.json",
|
Name: "workflow/event.json",
|
||||||
Mode: 0644,
|
Mode: 0644,
|
||||||
|
@ -641,20 +633,6 @@ func setActionRuntimeVars(rc *RunContext, env map[string]string) {
|
||||||
env["ACTIONS_RUNTIME_TOKEN"] = actionsRuntimeToken
|
env["ACTIONS_RUNTIME_TOKEN"] = actionsRuntimeToken
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) localCheckoutPath(ctx context.Context) (string, bool) {
|
|
||||||
if rc.Config.NoSkipCheckout {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
ghContext := rc.getGithubContext(ctx)
|
|
||||||
for _, step := range rc.Run.Job().Steps {
|
|
||||||
if isLocalCheckout(ghContext, step) {
|
|
||||||
return step.With["path"], true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rc *RunContext) handleCredentials(ctx context.Context) (username, password string, err error) {
|
func (rc *RunContext) handleCredentials(ctx context.Context) (username, password string, err error) {
|
||||||
// TODO: remove below 2 lines when we can release act with breaking changes
|
// TODO: remove below 2 lines when we can release act with breaking changes
|
||||||
username = rc.Config.Secrets["DOCKER_USERNAME"]
|
username = rc.Config.Secrets["DOCKER_USERNAME"]
|
||||||
|
|
|
@ -110,8 +110,13 @@ func (sar *stepActionRemote) main() common.Executor {
|
||||||
runStepExecutor(sar, stepStageMain, func(ctx context.Context) error {
|
runStepExecutor(sar, stepStageMain, func(ctx context.Context) error {
|
||||||
github := sar.RunContext.getGithubContext(ctx)
|
github := sar.RunContext.getGithubContext(ctx)
|
||||||
if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout {
|
if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout {
|
||||||
common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied")
|
if sar.RunContext.Config.BindWorkdir {
|
||||||
return nil
|
common.Logger(ctx).Debugf("Skipping local actions/checkout because you bound your workspace")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
eval := sar.RunContext.NewExpressionEvaluator(ctx)
|
||||||
|
copyToPath := filepath.Join(sar.RunContext.Config.ContainerWorkdir(), eval.Interpolate(ctx, sar.Step.With["path"]))
|
||||||
|
return sar.RunContext.JobContainer.CopyDir(copyToPath, sar.RunContext.Config.Workdir+string(filepath.Separator)+".", sar.RunContext.Config.UseGitIgnore)(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), strings.ReplaceAll(sar.Step.Uses, "/", "-"))
|
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), strings.ReplaceAll(sar.Step.Uses, "/", "-"))
|
||||||
|
|
Loading…
Reference in New Issue