Skip to content

Commit c3fb686

Browse files
ChristopherHXcplee
andauthored
fix: localcheckout mock (nektos#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>
1 parent 7105919 commit c3fb686

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

pkg/runner/run_context.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,6 @@ func (rc *RunContext) startJobContainer() common.Executor {
173173
Hostname: hostname,
174174
})
175175

176-
var copyWorkspace bool
177-
var copyToPath string
178-
if !rc.Config.BindWorkdir {
179-
copyToPath, copyWorkspace = rc.localCheckoutPath(ctx)
180-
copyToPath = filepath.Join(rc.Config.ContainerWorkdir(), copyToPath)
181-
}
182-
183176
return common.NewPipelineExecutor(
184177
rc.JobContainer.Pull(rc.Config.ForcePull),
185178
rc.stopJobContainer(),
@@ -188,7 +181,6 @@ func (rc *RunContext) startJobContainer() common.Executor {
188181
rc.JobContainer.UpdateFromImageEnv(&rc.Env),
189182
rc.JobContainer.UpdateFromEnv("/etc/environment", &rc.Env),
190183
rc.JobContainer.Exec([]string{"mkdir", "-m", "0777", "-p", ActPath}, rc.Env, "root", ""),
191-
rc.JobContainer.CopyDir(copyToPath, rc.Config.Workdir+string(filepath.Separator)+".", rc.Config.UseGitIgnore).IfBool(copyWorkspace),
192184
rc.JobContainer.Copy(ActPath+"/", &container.FileEntry{
193185
Name: "workflow/event.json",
194186
Mode: 0644,
@@ -641,20 +633,6 @@ func setActionRuntimeVars(rc *RunContext, env map[string]string) {
641633
env["ACTIONS_RUNTIME_TOKEN"] = actionsRuntimeToken
642634
}
643635

644-
func (rc *RunContext) localCheckoutPath(ctx context.Context) (string, bool) {
645-
if rc.Config.NoSkipCheckout {
646-
return "", false
647-
}
648-
649-
ghContext := rc.getGithubContext(ctx)
650-
for _, step := range rc.Run.Job().Steps {
651-
if isLocalCheckout(ghContext, step) {
652-
return step.With["path"], true
653-
}
654-
}
655-
return "", false
656-
}
657-
658636
func (rc *RunContext) handleCredentials(ctx context.Context) (username, password string, err error) {
659637
// TODO: remove below 2 lines when we can release act with breaking changes
660638
username = rc.Config.Secrets["DOCKER_USERNAME"]

pkg/runner/step_action_remote.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,13 @@ func (sar *stepActionRemote) main() common.Executor {
110110
runStepExecutor(sar, stepStageMain, func(ctx context.Context) error {
111111
github := sar.RunContext.getGithubContext(ctx)
112112
if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout {
113-
common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied")
114-
return nil
113+
if sar.RunContext.Config.BindWorkdir {
114+
common.Logger(ctx).Debugf("Skipping local actions/checkout because you bound your workspace")
115+
return nil
116+
}
117+
eval := sar.RunContext.NewExpressionEvaluator(ctx)
118+
copyToPath := filepath.Join(sar.RunContext.Config.ContainerWorkdir(), eval.Interpolate(ctx, sar.Step.With["path"]))
119+
return sar.RunContext.JobContainer.CopyDir(copyToPath, sar.RunContext.Config.Workdir+string(filepath.Separator)+".", sar.RunContext.Config.UseGitIgnore)(ctx)
115120
}
116121

117122
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), strings.ReplaceAll(sar.Step.Uses, "/", "-"))

0 commit comments

Comments
 (0)