-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* more next-backend functionality added
- Loading branch information
Showing
34 changed files
with
2,174 additions
and
771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ on: | |
push: | ||
branches: | ||
- develop # change to main if needed | ||
- feat/next2 | ||
- feat/next3 | ||
|
||
jobs: | ||
deploy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ci_backends | ||
|
||
import ( | ||
"github.com/diggerhq/digger/backend/utils" | ||
"github.com/diggerhq/digger/libs/spec" | ||
) | ||
|
||
type CiBackend interface { | ||
TriggerWorkflow(spec spec.Spec, runName string, vcsToken string) error | ||
} | ||
|
||
type JenkinsCi struct{} | ||
|
||
type CiBackendOptions struct { | ||
GithubClientProvider utils.GithubClientProvider | ||
GithubInstallationId int64 | ||
GitlabProjectId int | ||
GitlabmergeRequestEventName string | ||
GitlabCIPipelineID string | ||
GitlabCIPipelineIID int | ||
GitlabCIMergeRequestID int | ||
GitlabCIMergeRequestIID int | ||
GitlabCIProjectName string | ||
GitlabciprojectNamespace string | ||
GitlabciprojectId int | ||
GitlabciprojectNamespaceId int | ||
GitlabDiscussionId string | ||
RepoFullName string | ||
RepoOwner string | ||
RepoName string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ci_backends | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
orchestrator_scheduler "github.com/diggerhq/digger/libs/scheduler" | ||
"github.com/diggerhq/digger/libs/spec" | ||
"github.com/google/go-github/v61/github" | ||
"log" | ||
) | ||
|
||
type GithubActionCi struct { | ||
Client *github.Client | ||
} | ||
|
||
func (g GithubActionCi) TriggerWorkflow(spec spec.Spec, runName string, vcsToken string) error { | ||
log.Printf("TriggerGithubWorkflow: repoOwner: %v, repoName: %v, commentId: %v", spec.VCS.RepoOwner, spec.VCS.RepoName, spec.CommentId) | ||
client := g.Client | ||
specBytes, err := json.Marshal(spec) | ||
|
||
inputs := orchestrator_scheduler.WorkflowInput{ | ||
Spec: string(specBytes), | ||
RunName: runName, | ||
} | ||
|
||
_, err = client.Actions.CreateWorkflowDispatchEventByFileName(context.Background(), spec.VCS.RepoOwner, spec.VCS.RepoName, spec.VCS.WorkflowFile, github.CreateWorkflowDispatchEventRequest{ | ||
Ref: spec.Job.Branch, | ||
Inputs: inputs.ToMap(), | ||
}) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package ci_backends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ci_backends | ||
|
||
import ( | ||
"fmt" | ||
"github.com/diggerhq/digger/next/utils" | ||
"log" | ||
) | ||
|
||
type CiBackendProvider interface { | ||
GetCiBackend(options CiBackendOptions) (CiBackend, error) | ||
} | ||
|
||
type DefaultBackendProvider struct{} | ||
|
||
func (d DefaultBackendProvider) GetCiBackend(options CiBackendOptions) (CiBackend, error) { | ||
client, _, err := utils.GetGithubClient(options.GithubClientProvider, options.GithubInstallationId, options.RepoFullName) | ||
if err != nil { | ||
log.Printf("GetCiBackend: could not get github client: %v", err) | ||
return nil, fmt.Errorf("could not get github client: %v", err) | ||
} | ||
backend := &GithubActionCi{ | ||
Client: client, | ||
} | ||
return backend, nil | ||
} |
Oops, something went wrong.