feat: load every environment from --env-file to workflow (#184)

* feat: load every environment from --env-file to workflow

* fix: pass dotenv's environments through by context

* updates to support --secret-file

Co-authored-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
jony montana
2020-04-18 01:04:40 +08:00
committed by GitHub
parent f6e37a8d67
commit 2f395475b0
10 changed files with 47 additions and 30 deletions

View File

@@ -3,7 +3,6 @@ package runner
import (
"context"
"fmt"
"os"
"path/filepath"
"testing"
@@ -110,18 +109,8 @@ func TestRunEventSecrets(t *testing.T) {
workdir, err := filepath.Abs("testdata")
assert.NilError(t, err, workflowPath)
_ = godotenv.Load(filepath.Join(workdir, workflowPath, ".env"))
secrets := make(map[string]string)
for _, secret := range []string{
"MY_SECRET",
"MULTILINE_SECRET",
"JSON_SECRET",
} {
if env, ok := os.LookupEnv(secret); ok && env != "" {
secrets[secret] = env
}
}
env, _ := godotenv.Read(filepath.Join(workdir, workflowPath, ".env"))
secrets, _ := godotenv.Read(filepath.Join(workdir, workflowPath, ".secrets"))
runnerConfig := &Config{
Workdir: workdir,
@@ -129,6 +118,7 @@ func TestRunEventSecrets(t *testing.T) {
Platforms: platforms,
ReuseContainers: false,
Secrets: secrets,
Env: env,
}
runner, err := New(runnerConfig)
assert.NilError(t, err, workflowPath)