add support to override platform

Signed-off-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
Casey Lee
2020-02-19 22:16:40 -05:00
parent e4ee2ddab7
commit 543501a36a
8 changed files with 59 additions and 37 deletions

View File

@@ -12,6 +12,7 @@ type Input struct {
eventPath string
reuseContainers bool
secrets []string
platforms []string
dryrun bool
forcePull bool
logOutput bool

25
cmd/platforms.go Normal file
View File

@@ -0,0 +1,25 @@
package cmd
import (
"strings"
)
func (i *Input) newPlatforms() map[string]string {
platforms := map[string]string{
"ubuntu-latest": "ubuntu:18.04",
"ubuntu-18.04": "ubuntu:18.04",
"ubuntu-16.04": "ubuntu:16.04",
"windows-latest": "",
"windows-2019": "",
"macos-latest": "",
"macos-10.15": "",
}
for _, p := range i.platforms {
pParts := strings.Split(p, "=")
if len(pParts) == 2 {
platforms[pParts[0]] = pParts[1]
}
}
return platforms
}

View File

@@ -31,6 +31,7 @@ func Execute(ctx context.Context, version string) {
rootCmd.Flags().BoolP("list", "l", false, "list workflows")
rootCmd.Flags().StringP("job", "j", "", "run job")
rootCmd.Flags().StringArrayVarP(&input.secrets, "secret", "s", []string{}, "secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)")
rootCmd.Flags().StringArrayVarP(&input.platforms, "platform", "P", []string{}, "custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)")
rootCmd.Flags().BoolVarP(&input.reuseContainers, "reuse", "r", false, "reuse action containers to maintain state")
rootCmd.Flags().BoolVarP(&input.forcePull, "pull", "p", false, "pull docker image(s) if already present")
rootCmd.Flags().StringVarP(&input.eventPath, "eventpath", "e", "", "path to event JSON file")
@@ -98,6 +99,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
Workdir: input.Workdir(),
LogOutput: input.logOutput,
Secrets: newSecrets(input.secrets),
Platforms: input.newPlatforms(),
}
runner, err := runner.New(config)
if err != nil {