@@ -15,6 +15,7 @@ import (
15
15
"github.com/porter-dev/porter/api/server/shared/requestutils"
16
16
"github.com/porter-dev/porter/api/types"
17
17
"github.com/porter-dev/porter/internal/auth/token"
18
+ "github.com/porter-dev/porter/internal/encryption"
18
19
"github.com/porter-dev/porter/internal/integrations/ci/actions"
19
20
"github.com/porter-dev/porter/internal/models"
20
21
"github.com/porter-dev/porter/internal/telemetry"
@@ -117,6 +118,19 @@ func (c *OpenStackPRHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
117
118
prRequestBody = "Hello 👋 from Porter! Please merge this PR to enable preview environments for your application."
118
119
}
119
120
121
+ randStr , err := encryption .GenerateRandomBytes (4 )
122
+ if err != nil {
123
+ err = telemetry .Error (ctx , span , err , "error generating random bytes" )
124
+ c .HandleAPIError (w , r , apierrors .NewErrPassThroughToClient (err , http .StatusInternalServerError ))
125
+ return
126
+ }
127
+
128
+ prBranchName := fmt .Sprintf ("porter-stack-%s-%s" , appName , randStr )
129
+ // limit branch name to 100 characters for safety
130
+ if len (prBranchName ) > 100 {
131
+ prBranchName = prBranchName [:100 ]
132
+ }
133
+
120
134
if request .OpenPr || request .DeleteWorkflowFilename != "" {
121
135
openPRInput := & actions.GithubPROpts {
122
136
PRAction : actions .GithubPRAction_NewAppWorkflow ,
@@ -131,7 +145,7 @@ func (c *OpenStackPRHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
131
145
SecretName : secretName ,
132
146
PorterYamlPath : request .PorterYamlPath ,
133
147
Body : prRequestBody ,
134
- PRBranch : "porter-stack" ,
148
+ PRBranch : prBranchName ,
135
149
}
136
150
if request .DeleteWorkflowFilename != "" {
137
151
openPRInput .PRAction = actions .GithubPRAction_DeleteAppWorkflow
0 commit comments