chore: add support for passing commands via a file (#285)

This commit is contained in:
Kyle Leonhard 2024-10-23 18:56:07 -07:00 committed by GitHub
parent dc927a6123
commit 43270d582c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

13
main.go
View File

@ -131,6 +131,11 @@ func main() {
Usage: "execute single commands for github action", Usage: "execute single commands for github action",
EnvVars: []string{"INPUT_SCRIPT"}, EnvVars: []string{"INPUT_SCRIPT"},
}, },
&cli.StringFlag{
Name: "script.file",
Usage: "execute commands from a file for github action",
EnvVars: []string{"INPUT_SCRIPT_FILE"},
},
&cli.BoolFlag{ &cli.BoolFlag{
Name: "script.stop", Name: "script.stop",
Usage: "stop script after first failure", Usage: "stop script after first failure",
@ -271,6 +276,14 @@ func run(c *cli.Context) error {
scripts = append(scripts, s) scripts = append(scripts, s)
} }
if f := c.String("script.file"); f != "" {
s, err := os.ReadFile(f)
if err != nil {
return err
}
scripts = append(scripts, string(s))
}
plugin := Plugin{ plugin := Plugin{
Config: Config{ Config: Config{
Key: c.String("ssh-key"), Key: c.String("ssh-key"),