diff --git a/.gitignore b/.gitignore index 19ad47f..d8bfab7 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ _testmain.go vendor drone-telegram coverage.txt +.env diff --git a/README.md b/README.md index 3165426..7db908a 100644 --- a/README.md +++ b/README.md @@ -83,3 +83,13 @@ docker run --rm \ -w $(pwd) \ appleboy/drone-telegram ``` + +Load all environments from file. + +```bash +docker run --rm \ + -e ENV_FILE=your_env_file_path \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + appleboy/drone-telegram +``` diff --git a/main.go b/main.go index 1148548..a2c9847 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "os" + "github.com/joho/godotenv" _ "github.com/joho/godotenv/autoload" "github.com/urfave/cli" ) @@ -156,11 +157,20 @@ func main() { Usage: "job finished", EnvVar: "DRONE_JOB_FINISHED", }, + cli.StringFlag{ + Name: "env-file", + Usage: "source env file", + EnvVar: "ENV_FILE", + }, } app.Run(os.Args) } func run(c *cli.Context) error { + if c.String("env-file") != "" { + _ = godotenv.Load(c.String("env-file")) + } + plugin := Plugin{ Repo: Repo{ Owner: c.String("repo.owner"),