Pārlūkot izejas kodu

Revert "GithubActions: remove WebhookToken field"

This reverts commit 87c415c9e15bbaf6b1cbd4bb2c795d89db24fb0b.
Anukul Sangwan 4 gadi atpakaļ
vecāks
revīzija
af9e2cf28e

+ 22 - 6
internal/integrations/ci/actions/actions.go

@@ -32,11 +32,12 @@ type GithubActions struct {
 	GithubAppSecretPath  string
 	GithubInstallationID uint
 
-	PorterToken string
-	BuildEnv    map[string]string
-	ProjectID   uint
-	ClusterID   uint
-	ReleaseName string
+	WebhookToken string
+	PorterToken  string
+	BuildEnv     map[string]string
+	ProjectID    uint
+	ClusterID    uint
+	ReleaseName  string
 
 	GitBranch      string
 	DockerFilePath string
@@ -100,8 +101,17 @@ func (g *GithubActions) Cleanup() error {
 
 	g.defaultBranch = repo.GetDefaultBranch()
 
+	// delete the webhook token secret
+	err = g.deleteGithubSecret(client, g.getWebhookSecretName())
+
+	if err != nil {
+		return err
+	}
+
 	// delete the env secret
-	if err := g.deleteGithubSecret(client, g.getBuildEnvSecretName()); err != nil {
+	err = g.deleteGithubSecret(client, g.getBuildEnvSecretName())
+
+	if err != nil {
 		return err
 	}
 
@@ -294,6 +304,12 @@ func (g *GithubActions) createEnvSecret(client *github.Client) error {
 	return g.createGithubSecret(client, secretName, strings.Join(lines, "\n"))
 }
 
+func (g *GithubActions) getWebhookSecretName() string {
+	return fmt.Sprintf("WEBHOOK_%s", strings.Replace(
+		strings.ToUpper(g.ReleaseName), "-", "_", -1),
+	)
+}
+
 func (g *GithubActions) getBuildEnvSecretName() string {
 	return fmt.Sprintf("ENV_%s", strings.Replace(
 		strings.ToUpper(g.ReleaseName), "-", "_", -1),

+ 1 - 0
server/api/deploy_handler.go

@@ -380,6 +380,7 @@ func (app *App) HandleUninstallTemplate(w http.ResponseWriter, r *http.Request)
 					GitRepoOwner:           repoSplit[0],
 					Repo:                   *app.Repo,
 					GithubConf:             app.GithubProjectConf,
+					WebhookToken:           release.WebhookToken,
 					ProjectID:              uint(projID),
 					ReleaseName:            name,
 					GitBranch:              gitAction.GitBranch,

+ 1 - 0
server/api/git_action_handler.go

@@ -165,6 +165,7 @@ func (app *App) createGitActionFromForm(
 		GitRepoOwner:           repoSplit[0],
 		Repo:                   *app.Repo,
 		GithubConf:             app.GithubProjectConf,
+		WebhookToken:           release.WebhookToken,
 		ProjectID:              uint(projID),
 		ReleaseName:            name,
 		GitBranch:              gitAction.GitBranch,

+ 2 - 0
server/api/release_handler.go

@@ -1117,6 +1117,7 @@ func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
 					GitRepoOwner:           repoSplit[0],
 					Repo:                   *app.Repo,
 					GithubConf:             app.GithubProjectConf,
+					WebhookToken:           release.WebhookToken,
 					ProjectID:              uint(projID),
 					ReleaseName:            name,
 					GitBranch:              gitAction.GitBranch,
@@ -1535,6 +1536,7 @@ func (app *App) HandleRollbackRelease(w http.ResponseWriter, r *http.Request) {
 					GitRepoOwner:           repoSplit[0],
 					Repo:                   *app.Repo,
 					GithubConf:             app.GithubProjectConf,
+					WebhookToken:           release.WebhookToken,
 					ProjectID:              uint(projID),
 					ReleaseName:            name,
 					GitBranch:              gitAction.GitBranch,