Просмотр исходного кода

add porter secret to github action integration

Alexander Belanger 5 лет назад
Родитель
Сommit
b6f5f03e56
1 измененных файлов с 13 добавлено и 0 удалено
  1. 13 0
      internal/integrations/ci/actions/actions.go

+ 13 - 0
internal/integrations/ci/actions/actions.go

@@ -23,6 +23,8 @@ type GithubActions struct {
 	GithubConf *oauth2.Config
 
 	WebhookToken string
+	PorterToken  string
+	ProjectID    uint
 	ReleaseName  string
 }
 
@@ -40,6 +42,13 @@ func (g *GithubActions) Setup() error {
 		return err
 	}
 
+	// create a new secret with a porter token
+	err = g.createGithubSecret(client, g.getPorterTokenSecretName(), g.PorterToken)
+
+	if err != nil {
+		return err
+	}
+
 	return nil
 }
 
@@ -133,3 +142,7 @@ func (g *GithubActions) getWebhookSecretName() string {
 		strings.ToUpper(g.ReleaseName), "-", "_", -1),
 	)
 }
+
+func (g *GithubActions) getPorterTokenSecretName() string {
+	return fmt.Sprintf("PORTER_TOKEN_%d", g.ProjectID)
+}