mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
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:
parent
5e7ec329bd
commit
3bb919f266
9 changed files with 46 additions and 30 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue