Composite action (#608)
* Refactor maybeCopyToActionDir * Use maybeCopyToActionDir for model.ActionRunsUsingComposite
This commit is contained in:
parent
cec63488f3
commit
020d6a6083
2 changed files with 19 additions and 11 deletions
1
pkg/runner/runner_test.go
Executable file → Normal file
1
pkg/runner/runner_test.go
Executable file → Normal file
|
@ -102,7 +102,6 @@ func TestRunEvent(t *testing.T) {
|
||||||
|
|
||||||
// single test for different architecture: linux/arm64
|
// single test for different architecture: linux/arm64
|
||||||
{"testdata", "basic", "push", "", platforms, "linux/arm64"},
|
{"testdata", "basic", "push", "", platforms, "linux/arm64"},
|
||||||
|
|
||||||
}
|
}
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
|
|
||||||
|
|
|
@ -408,18 +408,23 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
switch action.Runs.Using {
|
maybeCopyToActionDir := func() error {
|
||||||
case model.ActionRunsUsingNode12:
|
if step.Type() != model.StepTypeUsesActionRemote {
|
||||||
if step.Type() == model.StepTypeUsesActionRemote {
|
return nil
|
||||||
|
}
|
||||||
err := removeGitIgnore(actionDir)
|
err := removeGitIgnore(actionDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = rc.JobContainer.CopyDir(containerActionDir+"/", actionDir, rc.Config.UseGitIgnore)(ctx)
|
return rc.JobContainer.CopyDir(containerActionDir+"/", actionDir, rc.Config.UseGitIgnore)(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch action.Runs.Using {
|
||||||
|
case model.ActionRunsUsingNode12:
|
||||||
|
err := maybeCopyToActionDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
containerArgs := []string{"node", path.Join(containerActionDir, actionName, actionPath, action.Runs.Main)}
|
containerArgs := []string{"node", path.Join(containerActionDir, actionName, actionPath, action.Runs.Main)}
|
||||||
log.Debugf("executing remote job container: %s", containerArgs)
|
log.Debugf("executing remote job container: %s", containerArgs)
|
||||||
return rc.execJobContainer(containerArgs, sc.Env)(ctx)
|
return rc.execJobContainer(containerArgs, sc.Env)(ctx)
|
||||||
|
@ -488,6 +493,10 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe
|
||||||
stepContainer.Remove().IfBool(!rc.Config.ReuseContainers),
|
stepContainer.Remove().IfBool(!rc.Config.ReuseContainers),
|
||||||
)(ctx)
|
)(ctx)
|
||||||
case model.ActionRunsUsingComposite:
|
case model.ActionRunsUsingComposite:
|
||||||
|
err := maybeCopyToActionDir()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
for outputName, output := range action.Outputs {
|
for outputName, output := range action.Outputs {
|
||||||
re := regexp.MustCompile(`\${{ steps\.([a-zA-Z_][a-zA-Z0-9_-]+)\.outputs\.([a-zA-Z_][a-zA-Z0-9_-]+) }}`)
|
re := regexp.MustCompile(`\${{ steps\.([a-zA-Z_][a-zA-Z0-9_-]+)\.outputs\.([a-zA-Z_][a-zA-Z0-9_-]+) }}`)
|
||||||
matches := re.FindStringSubmatch(output.Value)
|
matches := re.FindStringSubmatch(output.Value)
|
||||||
|
|
Loading…
Reference in a new issue