add support to override platform

Signed-off-by: Casey Lee <[email protected]>
This commit is contained in:
Casey Lee committed 2020-02-20 21:06:15 -05:00
1 parent e4ee2ddab7
commit 543501a36a
8 files changed
+59 -37

No files matched your search

+2 -15
View File
@@ -51,7 +51,7 @@ func (rc *RunContext) newStepExecutor(step *model.Step) common.Executor {
containerSpec.Options = job.Container.Options
} else {
platformName := rc.ExprEval.Interpolate(rc.Run.Job().RunsOn)
containerSpec.Image = platformImage(platformName)
containerSpec.Image = rc.Config.Platforms[strings.ToLower(platformName)]
}
return common.NewPipelineExecutor(
rc.setupEnv(containerSpec, step),
@@ -162,24 +162,11 @@ func (rc *RunContext) setupShellCommand(containerSpec *model.ContainerSpec, shel
return err
}
containerPath := fmt.Sprintf("/github/home/%s", filepath.Base(tempScript.Name()))
containerSpec.Args = strings.Replace(shellCommand, "{0}", containerPath, 1)
containerSpec.Entrypoint = strings.Replace(shellCommand, "{0}", containerPath, 1)
return nil
}
}
func platformImage(platform string) string {
switch strings.ToLower(platform) {
case "ubuntu-latest", "ubuntu-18.04":
return "ubuntu:18.04"
case "ubuntu-16.04":
return "ubuntu:16.04"
case "windows-latest", "windows-2019", "macos-latest", "macos-10.15":
return ""
default:
return ""
}
}
func (rc *RunContext) setupAction(containerSpec *model.ContainerSpec, actionDir string) common.Executor {
return func(ctx context.Context) error {
f, err := os.Open(filepath.Join(actionDir, "action.yml"))