mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-05-09 18:23:21 +08:00
Load PLUGIN_ENV_FILE before app is run (#112)
This commit is contained in:
parent
84cb184039
commit
f92f762c9d
13
main.go
13
main.go
@ -21,6 +21,11 @@ func main() {
|
|||||||
Version = fmt.Sprintf("1.3.1+%s", build)
|
Version = fmt.Sprintf("1.3.1+%s", build)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load env-file if it exists first
|
||||||
|
if filename, found := os.LookupEnv("PLUGIN_ENV_FILE"); found {
|
||||||
|
_ = godotenv.Load(filename)
|
||||||
|
}
|
||||||
|
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "Drone SSH"
|
app.Name = "Drone SSH"
|
||||||
app.Usage = "Executing remote ssh commands"
|
app.Usage = "Executing remote ssh commands"
|
||||||
@ -87,10 +92,6 @@ func main() {
|
|||||||
Usage: "execute commands",
|
Usage: "execute commands",
|
||||||
EnvVar: "PLUGIN_SCRIPT,SSH_SCRIPT",
|
EnvVar: "PLUGIN_SCRIPT,SSH_SCRIPT",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
|
||||||
Name: "env-file",
|
|
||||||
Usage: "source env file",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "proxy.ssh-key",
|
Name: "proxy.ssh-key",
|
||||||
Usage: "private ssh key of proxy",
|
Usage: "private ssh key of proxy",
|
||||||
@ -185,10 +186,6 @@ REPOSITORY:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run(c *cli.Context) error {
|
func run(c *cli.Context) error {
|
||||||
if c.String("env-file") != "" {
|
|
||||||
_ = godotenv.Load(c.String("env-file"))
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Config: Config{
|
Config: Config{
|
||||||
Key: c.String("ssh-key"),
|
Key: c.String("ssh-key"),
|
||||||
|
Loading…
Reference in New Issue
Block a user