Skip to content

Commit

Permalink
Updated github provider
Browse files Browse the repository at this point in the history
  • Loading branch information
futugyou committed Jan 11, 2025
1 parent 07bd0b8 commit a1b63bc
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 26 deletions.
6 changes: 3 additions & 3 deletions infr-project/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1954,13 +1954,13 @@ const docTemplate = `{
"createdAt": {
"type": "string"
},
"id": {
"environment": {
"type": "string"
},
"name": {
"id": {
"type": "string"
},
"plan": {
"name": {
"type": "string"
},
"readyState": {
Expand Down
6 changes: 3 additions & 3 deletions infr-project/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1943,13 +1943,13 @@
"createdAt": {
"type": "string"
},
"id": {
"environment": {
"type": "string"
},
"name": {
"id": {
"type": "string"
},
"plan": {
"name": {
"type": "string"
},
"readyState": {
Expand Down
4 changes: 2 additions & 2 deletions infr-project/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ definitions:
type: string
createdAt:
type: string
environment:
type: string
id:
type: string
name:
type: string
plan:
type: string
readyState:
type: string
readySubstate:
Expand Down
24 changes: 9 additions & 15 deletions infr-project/platform_provider/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,18 @@ func (g *GithubClient) GetProjectAsync(ctx context.Context, filter ProjectFilter
}
}

runs := map[string]Deployment{}
if gitRuns, _, err := g.client.Actions.ListRepositoryWorkflowRuns(ctx, GITHUB_OWNER, filter.Name, &github.ListWorkflowRunsOptions{
Branch: repository.GetDefaultBranch(),
deployments := map[string]Deployment{}
if gitDeployments, _, err := g.client.Repositories.ListDeployments(ctx, GITHUB_OWNER, filter.Name, &github.DeploymentsListOptions{
ListOptions: github.ListOptions{Page: 1, PerPage: 20},
}); err != nil {
log.Println(err.Error())
} else {
for _, v := range gitRuns.WorkflowRuns {
badgeUrl, badgeMarkdown := g.buildGithubWorkflowBadge(v.GetName(), v.GetStatus(), v.GetURL())
runs[fmt.Sprintf("%d", v.GetID())] = Deployment{
ID: fmt.Sprintf("%d", v.GetID()),
Name: v.GetName(),
Plan: "",
ReadyState: v.GetStatus(),
ReadySubstate: v.GetStatus(),
CreatedAt: v.GetCreatedAt().Format(time.RFC3339Nano),
BadgeURL: badgeUrl,
BadgeMarkdown: badgeMarkdown,
for _, v := range gitDeployments {
deployments[fmt.Sprintf("%d", v.GetID())] = Deployment{
ID: fmt.Sprintf("%d", v.GetID()),
Name: v.GetTask(),
Environment: v.GetEnvironment(),
CreatedAt: v.GetCreatedAt().Format(time.RFC3339Nano),
}
}
}
Expand All @@ -286,7 +280,7 @@ func (g *GithubClient) GetProjectAsync(ctx context.Context, filter ProjectFilter
project.WebHooks = hooks
project.EnvironmentVariables = envs
project.Workflows = wfs
project.Deployments = runs
project.Deployments = deployments
project.Environments = environments
resultChan <- &project
}()
Expand Down
2 changes: 1 addition & 1 deletion infr-project/platform_provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Workflow struct {
type Deployment struct {
ID string
Name string
Plan string
Environment string
ReadyState string
ReadySubstate string
CreatedAt string
Expand Down
2 changes: 1 addition & 1 deletion infr-project/platform_provider/vercel.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (g *VercelClient) buildVercelDeployment(vercelDeployments []vercel.LatestDe
deployments[v.ID] = Deployment{
ID: v.ID,
Name: v.Name,
Plan: v.Plan,
Environment: v.Target,
ReadyState: v.ReadyState,
ReadySubstate: v.ReadySubstate,
CreatedAt: tool.Int64ToTime(v.CreatedAt).Format(time.RFC3339Nano),
Expand Down
2 changes: 1 addition & 1 deletion infr-project/view_models/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ type Workflow struct {
type Deployment struct {
ID string `json:"id"`
Name string `json:"name"`
Plan string `json:"plan"`
Environment string `json:"environment"`
ReadyState string `json:"readyState"`
ReadySubstate string `json:"readySubstate"`
CreatedAt string `json:"createdAt"`
Expand Down

0 comments on commit a1b63bc

Please sign in to comment.