1
1
mirror of https://github.com/nektos/act.git synced 2024-09-19 16:27:50 +03:00

fix: use new platforms after survey, check working dir for .actrc (#577)

This commit is contained in:
hackercat 2021-03-29 16:58:00 +02:00 committed by GitHub
parent f5a02581c2
commit 780a8a061c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -198,11 +198,11 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
// check platforms
if len(input.platforms) == 0 {
actrc := []string{
filepath.Join(os.Getenv("HOME"), ".actrc"),
}
_, err = os.Stat(actrc[0])
if os.IsNotExist(err) {
actrcHome := filepath.Join(os.Getenv("HOME"), ".actrc")
actrcCwd := filepath.Join(".", ".actrc")
_, errHome := os.Stat(actrcHome)
_, errCwd := os.Stat(actrcCwd)
if os.IsNotExist(errHome) && os.IsNotExist(errCwd) {
var answer string
confirmation := &survey.Select{
Message: "Please choose the default image you want to use with act:\n\n - Large size image: +20GB Docker image, includes almost all tools used on GitHub Actions (IMPORTANT: currently only ubuntu-18.04 platform is available)\n - Medium size image: ~500MB, includes only necessary tools to bootstrap actions and aims to be compatible with all actions\n - Micro size image: <200MB, contains only NodeJS required to bootstrap actions, doesn't work with all actions\n\nDefault image and other options can be changed manually in ~/.actrc (please refer to https://github.com/nektos/act#configuration for additional information about file structure)",
@ -210,7 +210,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
Default: "Medium",
Options: []string{"Large", "Medium", "Micro"},
}
configFileArgs := make([]string, 0)
err := survey.AskOne(confirmation, &answer)
if err != nil {
log.Error(err)
@ -226,7 +226,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
option = "-P ubuntu-latest=node:12.20.1-buster-slim\n-P ubuntu-20.04=node:12.20.1-buster-slim\n-P ubuntu-18.04=node:12.20.1-buster-slim\n-P ubuntu-16.04=node:12.20.1-stretch-slim"
}
f, err := os.Create(actrc[0])
f, err := os.Create(actrcHome)
if err != nil {
log.Fatal(err)
}
@ -242,8 +242,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
log.Fatal(err)
}
configFileArgs = append(configFileArgs, readArgsFile(actrc[0])...)
cmd.SetArgs(configFileArgs)
input.platforms = readArgsFile(actrcHome)
}
}