Repository: nektos/act (language: go)

Issue:
Rough handling for local checkouts in composite actions
This seems to work for me for #1112

Tested with:

```sh
git clone git@github.com:check-spelling/lunr.js.git
git checkout spell-check
 ~/code/nektos/act/dist/local/act -W .github/workflows/spelling.yml --container-architecture linux/arm64 -s GITHUB_TOKEN=$GITHUB_TOKEN
```



Discussion / hints:
@jsoref this pull request has failed checks 🛠
Note: I don't have the bandwidth to figure out how to make this do the right thing. So, it's more of a pointer which should hopefully help someone else fix this properly.
...Isn't this logically equivalent to `act --no-skip-checkout -W .github/workflows/spelling.yml --container-architecture linux/arm64 -s GITHUB_TOKEN=$GITHUB_TOKEN`?
The only issue with that command is, that act always pulls from github.com or the specified github instance.

_I checked the readme and saw that this new cli option is missing, but is released in act `v0.2.26`_
> I checked the readme and saw that this new cli option is missing

I would love to get rid of that section from readme
It'd be better if the code properly stubbed checkout in composite actions...
> I would love to get rid of that section from readme

I would approve removing this section.

> It'd be better if the code properly stubbed checkout in composite actions...

Yes, we need a mock which calls the docker cp once it sees actions/checkout to the specified path and remove the docker cp from startcontainer. I don't depend on this local checkout functionality, so only low priority for me.

**EDIT**
https://github.com/nektos/act/issues/1193 needs to be fixed first, otherwise absolutly no local action will work.

Fix patch:
diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go
index c50005f43f6..3afc364f7a2 100644
--- a/pkg/runner/run_context.go
+++ b/pkg/runner/run_context.go
@@ -173,13 +173,6 @@ func (rc *RunContext) startJobContainer() common.Executor {
 			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(
 			rc.JobContainer.Pull(rc.Config.ForcePull),
 			rc.stopJobContainer(),
@@ -188,7 +181,6 @@ func (rc *RunContext) startJobContainer() common.Executor {
 			rc.JobContainer.UpdateFromImageEnv(&rc.Env),
 			rc.JobContainer.UpdateFromEnv("/etc/environment", &rc.Env),
 			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{
 				Name: "workflow/event.json",
 				Mode: 0644,
@@ -641,20 +633,6 @@ func setActionRuntimeVars(rc *RunContext, env map[string]string) {
 	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) {
 	// TODO: remove below 2 lines when we can release act with breaking changes
 	username = rc.Config.Secrets["DOCKER_USERNAME"]
diff --git a/pkg/runner/step_action_remote.go b/pkg/runner/step_action_remote.go
index 82ce6b8823e..56b0ed57eba 100644
--- a/pkg/runner/step_action_remote.go
+++ b/pkg/runner/step_action_remote.go
@@ -110,8 +110,13 @@ func (sar *stepActionRemote) main() common.Executor {
 		runStepExecutor(sar, stepStageMain, func(ctx context.Context) error {
 			github := sar.RunContext.getGithubContext(ctx)
 			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")
-				return nil
+				if sar.RunContext.Config.BindWorkdir {
+					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, "/", "-"))


Test patch: