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)
|
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 {
|
maybeCopyToActionDir := func() error {
|
||||||
sc.Env["GITHUB_ACTION_PATH"] = containerActionDir
|
sc.Env["GITHUB_ACTION_PATH"] = containerActionDir
|
||||||
if step.Type() != model.StepTypeUsesActionRemote {
|
if step.Type() != model.StepTypeUsesActionRemote {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err := removeGitIgnore(actionDir)
|
if err := removeGitIgnore(actionDir); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
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 {
|
switch action.Runs.Using {
|
||||||
case model.ActionRunsUsingNode12:
|
case model.ActionRunsUsingNode12:
|
||||||
err := maybeCopyToActionDir()
|
if err := maybeCopyToActionDir(); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
containerArgs := []string{"node", path.Join(containerActionDir, action.Runs.Main)}
|
containerArgs := []string{"node", path.Join(containerActionDir, action.Runs.Main)}
|
||||||
|
|
Loading…
Reference in a new issue