Skip to content

Commit

Permalink
Add workflow_id as an optional key column for `github_actions_repos…
Browse files Browse the repository at this point in the history
…itory_workflow_run` list calls (#465)
  • Loading branch information
tsibley authored Dec 26, 2024
1 parent 1a0b9dd commit 4634281
Showing 1 changed file with 23 additions and 1 deletion.
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

0 comments on commit 4634281

Please sign in to comment.