Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow_id as an optional key column for github_actions_repository_workflow_run list calls #465

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion github/table_github_actions_repository_workflow_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package github

import (
"context"
"strconv"

"github.com/google/go-github/v55/github"

Expand All @@ -19,6 +20,7 @@ func tableGitHubActionsRepositoryWorkflowRun() *plugin.Table {
Hydrate: tableGitHubRepoWorkflowRunList,
KeyColumns: []*plugin.KeyColumn{
{Name: "repository_full_name", Require: plugin.Required},
{Name: "workflow_id", Require: plugin.Optional},
{Name: "event", Require: plugin.Optional},
{Name: "head_branch", Require: plugin.Optional},
{Name: "status", Require: plugin.Optional},
Expand Down Expand Up @@ -110,8 +112,28 @@ func tableGitHubRepoWorkflowRunList(ctx context.Context, d *plugin.QueryData, h
}
}

var workflowId int64
if equalQuals["workflow_id"] != nil {
if equalQuals["workflow_id"].GetStringValue() != "" {
workflowId_, err := strconv.ParseInt(equalQuals["workflow_id"].GetStringValue(), 10, 64)
if err != nil {
panic(err)
}
workflowId = workflowId_
}
}

for {
workflowRuns, resp, err := client.Actions.ListRepositoryWorkflowRuns(ctx, owner, repo, opts)
var (
workflowRuns *github.WorkflowRuns
resp *github.Response
err error
)
if workflowId != 0 {
workflowRuns, resp, err = client.Actions.ListWorkflowRunsByID(ctx, owner, repo, workflowId, opts)
} else {
workflowRuns, resp, err = client.Actions.ListRepositoryWorkflowRuns(ctx, owner, repo, opts)
}
if err != nil {
return nil, err
}
Expand Down
Loading