Skip to content

Commit

Permalink
fix env merge order and set envs in nektos (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
raghavharness authored Aug 22, 2023
1 parent 5cb0021 commit b8020a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugin/github/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions plugin/github/execer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b8020a6

Please sign in to comment.