1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

fix #121 and #123 - add support for reading env variables from .env (#133)

This commit is contained in:
Casey Lee 2020-03-06 12:30:24 -08:00 committed by GitHub
parent c64bbd5c93
commit f9befb34a3
11 changed files with 620 additions and 0 deletions

View file

@ -12,6 +12,7 @@ import (
"github.com/nektos/act/pkg/common"
fswatch "github.com/andreaskoch/go-fswatch"
"github.com/joho/godotenv"
"github.com/nektos/act/pkg/model"
"github.com/nektos/act/pkg/runner"
gitignore "github.com/sabhiram/go-gitignore"
@ -45,7 +46,9 @@ func Execute(ctx context.Context, version string) {
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "verbose output")
rootCmd.PersistentFlags().BoolVarP(&input.noOutput, "quiet", "q", false, "disable logging of output from steps")
rootCmd.PersistentFlags().BoolVarP(&input.dryrun, "dryrun", "n", false, "dryrun mode")
rootCmd.PersistentFlags().StringVarP(&input.envfile, "env-file", "", ".env", "environment file to read")
rootCmd.SetArgs(args())
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
@ -91,6 +94,15 @@ func setupLogging(cmd *cobra.Command, args []string) {
func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
envfile := input.Envfile()
if _, err := os.Stat(envfile); err == nil {
log.Debugf("Loading environment from %s", envfile)
err := godotenv.Load(envfile)
if err != nil {
log.Fatalf("Error loading environment from %s: %v", envfile, err)
}
}
planner, err := model.NewWorkflowPlanner(input.WorkflowsPath())
if err != nil {
return err