fix: copy whole action dir to container (#774)
fixes https://github.com/nektos/act/issues/754 this will prevent actions from failing that use resources outside of the action directory
This commit is contained in:
parent
bea32d5651
commit
de44a505da
1 changed files with 12 additions and 6 deletions
|
@ -467,24 +467,30 @@ func (sc *StepContext) runAction(actionDir string, actionPath string, localActio
|
|||
|
||||
sc.Env = mergeMaps(sc.Env, action.Runs.Env)
|
||||
|
||||
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)
|
||||
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 {
|
||||
return nil
|
||||
}
|
||||
err := removeGitIgnore(actionDir)
|
||||
if err != nil {
|
||||
if err := removeGitIgnore(actionDir); err != nil {
|
||||
return err
|
||||
}
|
||||
return rc.JobContainer.CopyDir(containerActionDir+"/", actionLocation+"/", rc.Config.UseGitIgnore)(ctx)
|
||||
|
||||
var containerActionDirCopy string
|
||||
containerActionDirCopy = strings.TrimSuffix(containerActionDir, actionPath)
|
||||
log.Debug(containerActionDirCopy)
|
||||
|
||||
if !strings.HasSuffix(containerActionDirCopy, `/`) {
|
||||
containerActionDirCopy += `/`
|
||||
}
|
||||
return rc.JobContainer.CopyDir(containerActionDirCopy, actionDir+"/", rc.Config.UseGitIgnore)(ctx)
|
||||
}
|
||||
|
||||
switch action.Runs.Using {
|
||||
case model.ActionRunsUsingNode12:
|
||||
err := maybeCopyToActionDir()
|
||||
if err != nil {
|
||||
if err := maybeCopyToActionDir(); err != nil {
|
||||
return err
|
||||
}
|
||||
containerArgs := []string{"node", path.Join(containerActionDir, action.Runs.Main)}
|
||||
|
|
Loading…
Reference in a new issue