|
@@ -4,6 +4,8 @@ import (
|
|
|
"context"
|
|
"context"
|
|
|
"encoding/base64"
|
|
"encoding/base64"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
+ "net/http"
|
|
|
|
|
+
|
|
|
"github.com/bradleyfalzon/ghinstallation"
|
|
"github.com/bradleyfalzon/ghinstallation"
|
|
|
"github.com/google/go-github/v33/github"
|
|
"github.com/google/go-github/v33/github"
|
|
|
"github.com/porter-dev/porter/internal/models"
|
|
"github.com/porter-dev/porter/internal/models"
|
|
@@ -11,7 +13,6 @@ import (
|
|
|
"github.com/porter-dev/porter/internal/repository"
|
|
"github.com/porter-dev/porter/internal/repository"
|
|
|
"golang.org/x/crypto/nacl/box"
|
|
"golang.org/x/crypto/nacl/box"
|
|
|
"golang.org/x/oauth2"
|
|
"golang.org/x/oauth2"
|
|
|
- "net/http"
|
|
|
|
|
|
|
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
|
@@ -79,18 +80,6 @@ func (g *GithubActions) Setup() (string, error) {
|
|
|
return "", err
|
|
return "", err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- err = g.createGithubSecret(client, g.getProjectIDSecretName(), g.PorterToken)
|
|
|
|
|
-
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return "", err
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- err = g.createGithubSecret(client, g.getClusterIDSecretName(), g.PorterToken)
|
|
|
|
|
-
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return "", err
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// create a new secret with the build variables
|
|
// create a new secret with the build variables
|
|
|
err = g.createEnvSecret(client)
|
|
err = g.createEnvSecret(client)
|
|
|
|
|
|
|
@@ -144,19 +133,13 @@ func (g *GithubActions) Cleanup() error {
|
|
|
return g.deleteGithubFile(client, g.getPorterYMLFileName())
|
|
return g.deleteGithubFile(client, g.getPorterYMLFileName())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-type GithubActionEnvConfig struct {
|
|
|
|
|
- PorterToken string `yaml:"PORTER_TOKEN"`
|
|
|
|
|
- ProjectID string `yaml:"PORTER_PROJECT"`
|
|
|
|
|
- ClusterID string `yaml:"PORTER_CLUSTER"`
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
type GithubActionYAMLStep struct {
|
|
type GithubActionYAMLStep struct {
|
|
|
- Name string `yaml:"name,omitempty"`
|
|
|
|
|
- ID string `yaml:"id,omitempty"`
|
|
|
|
|
- Timeout uint64 `yaml:"timeout-minutes,omitempty"`
|
|
|
|
|
- Uses string `yaml:"uses,omitempty"`
|
|
|
|
|
- Run string `yaml:"run,omitempty"`
|
|
|
|
|
- Env GithubActionEnvConfig `yaml:"env,omitempty"`
|
|
|
|
|
|
|
+ Name string `yaml:"name,omitempty"`
|
|
|
|
|
+ ID string `yaml:"id,omitempty"`
|
|
|
|
|
+ Timeout uint64 `yaml:"timeout-minutes,omitempty"`
|
|
|
|
|
+ Uses string `yaml:"uses,omitempty"`
|
|
|
|
|
+ Run string `yaml:"run,omitempty"`
|
|
|
|
|
+ Env map[string]string `yaml:"env,omitempty"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type GithubActionYAMLOnPushBranches struct {
|
|
type GithubActionYAMLOnPushBranches struct {
|
|
@@ -184,17 +167,9 @@ func (g *GithubActions) GetGithubActionYAML() ([]byte, error) {
|
|
|
gaSteps := []GithubActionYAMLStep{
|
|
gaSteps := []GithubActionYAMLStep{
|
|
|
getCheckoutCodeStep(),
|
|
getCheckoutCodeStep(),
|
|
|
getDownloadPorterStep(),
|
|
getDownloadPorterStep(),
|
|
|
- getConfigurePorterStep(g.ServerURL, g.getPorterTokenSecretName(), g.getProjectIDSecretName(), g.getClusterIDSecretName(), g.ReleaseName),
|
|
|
|
|
|
|
+ getConfigurePorterStep(g.ServerURL, g.getPorterTokenSecretName(), g.ProjectID, g.ClusterID, g.ReleaseName),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //if g.DockerFilePath == "" {
|
|
|
|
|
- // gaSteps = append(gaSteps, getBuildPackPushStep(g.getBuildEnvSecretName(), g.FolderPath, g.ImageRepoURL))
|
|
|
|
|
- //} else {
|
|
|
|
|
- // gaSteps = append(gaSteps, getDockerBuildPushStep(g.getBuildEnvSecretName(), g.DockerFilePath, g.ImageRepoURL))
|
|
|
|
|
- //}
|
|
|
|
|
- //
|
|
|
|
|
- //gaSteps = append(gaSteps, deployPorterWebhookStep(g.ServerURL, g.getWebhookSecretName()))
|
|
|
|
|
-
|
|
|
|
|
branch := g.GitBranch
|
|
branch := g.GitBranch
|
|
|
|
|
|
|
|
if branch == "" {
|
|
if branch == "" {
|
|
@@ -366,14 +341,6 @@ func (g *GithubActions) getPorterTokenSecretName() string {
|
|
|
return fmt.Sprintf("PORTER_TOKEN_%d", g.ProjectID)
|
|
return fmt.Sprintf("PORTER_TOKEN_%d", g.ProjectID)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (g *GithubActions) getProjectIDSecretName() string {
|
|
|
|
|
- return fmt.Sprintf("PORTER_PROJECT_ID_%d", g.ProjectID)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (g *GithubActions) getClusterIDSecretName() string {
|
|
|
|
|
- return fmt.Sprintf("PORTER_CLUSTER_ID_%d", g.ProjectID)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
func (g *GithubActions) commitGithubFile(
|
|
func (g *GithubActions) commitGithubFile(
|
|
|
client *github.Client,
|
|
client *github.Client,
|
|
|
filename string,
|
|
filename string,
|