Skip to content

Commit

Permalink
Add 'pending_deployments' endpoint support (google#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGamba committed Jul 27, 2022
1 parent 3a432d6 commit c2073f1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions github/actions_workflow_runs.go
Expand Up @@ -94,6 +94,13 @@ type WorkflowRunAttemptOptions struct {
ExcludePullRequests *bool `url:"exclude_pull_requests,omitempty"`
}

// PendingDeploymentsRequest specificies body parameters to PendingDeployments
type PendingDeploymentsRequest struct {
EnvironmentIDs *[]int `json:"environment_ids"`
State *string `json:"state"`
Comment *string `json:"comment"`
}

func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
u, err := addOptions(endpoint, opts)
if err != nil {
Expand Down Expand Up @@ -321,3 +328,23 @@ func (s *ActionsService) GetWorkflowRunUsageByID(ctx context.Context, owner, rep

return workflowRunUsage, resp, nil
}

// PendingDeployments approve or reject pending deployments that are waiting on approval by a required reviewer.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#review-pending-deployments-for-a-workflow-run
func (s *ActionsService) PendingDeployments(ctx context.Context, owner, repo string, runID int64, request *PendingDeploymentsRequest) ([]*Deployment, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/pending_deployments", owner, repo, runID)

req, err := s.client.NewRequest("POST", u, request)
if err != nil {
return nil, nil, err
}

var deployments []*Deployment
resp, err := s.client.Do(ctx, req, &deployments)
if err != nil {
return nil, resp, err
}

return deployments, resp, nil
}

0 comments on commit c2073f1

Please sign in to comment.