Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ linters:
- DependabotEncryptedSecret
- DependencyGraphSnapshot
- DeploymentBranchPolicyRequest
- DeploymentRequest
- DeploymentStatusRequest
- EncryptedSecret
- EnterpriseSecurityAnalysisSettings
- ExternalGroup
Expand Down Expand Up @@ -413,7 +411,6 @@ linters:
- CreateTag.Type # TODO: Git
- DependabotEncryptedSecret.SelectedRepositoryIDs # TODO: Dependabot
- DependabotEncryptedSecret.Visibility # TODO: Dependabot
- DeploymentRequest.RequiredContexts # TODO: Deployments
- DismissalRestrictionsRequest.Apps # TODO: Repositories
- DismissalRestrictionsRequest.Teams # TODO: Repositories
- DismissalRestrictionsRequest.Users # TODO: Repositories
Expand Down
24 changes: 16 additions & 8 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 19 additions & 14 deletions github/repos_deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ type Deployment struct {

// DeploymentRequest represents a deployment request.
type DeploymentRequest struct {
Ref *string `json:"ref,omitempty"`
Task *string `json:"task,omitempty"`
AutoMerge *bool `json:"auto_merge,omitempty"`
RequiredContexts *[]string `json:"required_contexts,omitempty"`
Payload any `json:"payload,omitempty"`
Environment *string `json:"environment,omitempty"`
Description *string `json:"description,omitempty"`
TransientEnvironment *bool `json:"transient_environment,omitempty"`
ProductionEnvironment *bool `json:"production_environment,omitempty"`
Ref string `json:"ref"`
Task *string `json:"task,omitempty"`
AutoMerge *bool `json:"auto_merge,omitempty"`
// RequiredContexts is the status contexts to verify against commit status checks.
// If nil, all unique contexts are verified; an empty slice bypasses checking entirely.
RequiredContexts []string `json:"required_contexts,omitzero"`
Payload any `json:"payload,omitempty"`
Environment *string `json:"environment,omitempty"`
Description *string `json:"description,omitempty"`
TransientEnvironment *bool `json:"transient_environment,omitempty"`
ProductionEnvironment *bool `json:"production_environment,omitempty"`
}

// DeploymentsListOptions specifies the optional parameters to the
Expand Down Expand Up @@ -114,7 +116,7 @@ func (s *RepositoriesService) GetDeployment(ctx context.Context, owner, repo str
// GitHub API docs: https://docs.github.com/rest/deployments/deployments?apiVersion=2022-11-28#create-a-deployment
//
//meta:operation POST /repos/{owner}/{repo}/deployments
func (s *RepositoriesService) CreateDeployment(ctx context.Context, owner, repo string, body *DeploymentRequest) (*Deployment, *Response, error) {
func (s *RepositoriesService) CreateDeployment(ctx context.Context, owner, repo string, body DeploymentRequest) (*Deployment, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/deployments", owner, repo)

req, err := s.client.NewRequest(ctx, "POST", u, body)
Expand Down Expand Up @@ -170,9 +172,12 @@ type DeploymentStatus struct {
URL *string `json:"url,omitempty"`
}

// DeploymentStatusRequest represents a deployment request.
// DeploymentStatusRequest represents a deployment status request.
type DeploymentStatusRequest struct {
State *string `json:"state,omitempty"`
State string `json:"state"`
// TargetURL is the target URL to associate with this status.
// It's recommended to use LogURL instead, which replaces TargetURL.
TargetURL *string `json:"target_url,omitempty"`
LogURL *string `json:"log_url,omitempty"`
Description *string `json:"description,omitempty"`
Environment *string `json:"environment,omitempty"`
Expand Down Expand Up @@ -239,8 +244,8 @@ func (s *RepositoriesService) GetDeploymentStatus(ctx context.Context, owner, re
// GitHub API docs: https://docs.github.com/rest/deployments/statuses?apiVersion=2022-11-28#create-a-deployment-status
//
//meta:operation POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
func (s *RepositoriesService) CreateDeploymentStatus(ctx context.Context, owner, repo string, deployment int64, body *DeploymentStatusRequest) (*DeploymentStatus, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deployment)
func (s *RepositoriesService) CreateDeploymentStatus(ctx context.Context, owner, repo string, deploymentID int64, body DeploymentStatusRequest) (*DeploymentStatus, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deploymentID)

req, err := s.client.NewRequest(ctx, "POST", u, body)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions github/repos_deployments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestRepositoriesService_CreateDeployment(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

input := &DeploymentRequest{Ref: Ptr("1111"), Task: Ptr("deploy"), TransientEnvironment: Ptr(true)}
input := DeploymentRequest{Ref: "1111", Task: Ptr("deploy"), TransientEnvironment: Ptr(true)}

mux.HandleFunc("/repos/o/r/deployments", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestRepositoriesService_CreateDeploymentStatus(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

input := &DeploymentStatusRequest{State: Ptr("inactive"), Description: Ptr("deploy"), AutoInactive: Ptr(false)}
input := DeploymentStatusRequest{State: "inactive", Description: Ptr("deploy"), AutoInactive: Ptr(false)}

mux.HandleFunc("/repos/o/r/deployments/1/statuses", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
Expand Down
Loading