Explorar el Código

get correct branch name for deployment target (#3653)

ianedwards hace 2 años
padre
commit
ecd89e9df9
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      cli/cmd/v2/apply.go

+ 6 - 1
cli/cmd/v2/apply.go

@@ -389,7 +389,12 @@ func deploymentTargetFromConfig(ctx context.Context, client api.Client, projectI
 
 	if previewApply {
 		var branchName string
-		if os.Getenv("GITHUB_REF_NAME") != "" {
+
+		// branch name is set to different values in the GH env, depending on whether or not the workflow is triggered by a PR
+		// issue is being tracked here: https://github.com/github/docs/issues/15319
+		if os.Getenv("GITHUB_HEAD_REF") != "" {
+			branchName = os.Getenv("GITHUB_HEAD_REF")
+		} else if os.Getenv("GITHUB_REF_NAME") != "" {
 			branchName = os.Getenv("GITHUB_REF_NAME")
 		} else if branch, err := git.CurrentBranch(); err == nil {
 			branchName = branch