From b8020a6953d882f9c365c1f6f8eba418d65f427a Mon Sep 17 00:00:00 2001 From: Raghav Date: Tue, 22 Aug 2023 16:59:48 +0530 Subject: [PATCH] fix env merge order and set envs in nektos (#30) --- plugin/github/env.go | 4 ++-- plugin/github/execer.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin/github/env.go b/plugin/github/env.go index 9db1466..9aa0c39 100644 --- a/plugin/github/env.go +++ b/plugin/github/env.go @@ -64,7 +64,7 @@ func Environ(src []string) []string { // // github action environment variable docs: // https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables - dst = environ.Combine(dst, map[string]string{ + dst = environ.Combine(map[string]string{ "GITHUB_BASE_REF": dst["DRONE_TARGET_BRANCH"], "GITHUB_HEAD_REF": dst["DRONE_SOURCE_BRANCH"], "GITHUB_REF": dst["DRONE_COMMIT_REF"], @@ -78,7 +78,7 @@ func Environ(src []string) []string { "RUNNER_OS": ostype, "RUNNER_NAME": "HARNESS HOSTED", "RUNNER_TOOL_CACHE": runner_tool_cache, - }) + }, dst) if tagName != "" { dst["GITHUB_REF_NAME"] = tagName diff --git a/plugin/github/execer.go b/plugin/github/execer.go index 4eec308..5b4108e 100644 --- a/plugin/github/execer.go +++ b/plugin/github/execer.go @@ -77,6 +77,11 @@ func (e *Execer) Exec(ctx context.Context) error { } } + // append envs + for k, v := range envVars { + os.Args = append(os.Args, "--env", k+"="+v) + } + cmd.Execute(ctx, "1.1") if err := exportEnv(beforeStepEnvFile, afterStepEnvFile); err != nil {