|
|
@@ -743,7 +743,29 @@ func (t *DeploymentHook) PreApply() error {
|
|
|
},
|
|
|
)
|
|
|
|
|
|
- if err == nil {
|
|
|
+ if err != nil && strings.Contains(err.Error(), "not found") {
|
|
|
+ // in this case, create the deployment
|
|
|
+ _, err = t.client.CreateDeployment(
|
|
|
+ context.Background(),
|
|
|
+ t.projectID, t.gitInstallationID, t.clusterID,
|
|
|
+ t.repoOwner, t.repoName,
|
|
|
+ &types.CreateDeploymentRequest{
|
|
|
+ Namespace: t.namespace,
|
|
|
+ PullRequestID: t.prID,
|
|
|
+ CreateGHDeploymentRequest: &types.CreateGHDeploymentRequest{
|
|
|
+ ActionID: t.actionID,
|
|
|
+ },
|
|
|
+ GitHubMetadata: &types.GitHubMetadata{
|
|
|
+ PRName: t.prName,
|
|
|
+ RepoName: t.repoName,
|
|
|
+ RepoOwner: t.repoOwner,
|
|
|
+ CommitSHA: t.commitSHA,
|
|
|
+ PRBranchFrom: t.branchFrom,
|
|
|
+ PRBranchInto: t.branchInto,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ )
|
|
|
+ } else if err == nil {
|
|
|
_, err = t.client.UpdateDeployment(
|
|
|
context.Background(),
|
|
|
t.projectID, t.gitInstallationID, t.clusterID,
|