diff --git a/github/actions_artifacts.go b/github/actions_artifacts.go index 2b560fa05de..73641559db4 100644 --- a/github/actions_artifacts.go +++ b/github/actions_artifacts.go @@ -29,17 +29,21 @@ type ArtifactWorkflowRun struct { // // GitHub API docs: https://docs.github.com/rest/actions/artifacts type Artifact struct { - ID *int64 `json:"id,omitempty"` - NodeID *string `json:"node_id,omitempty"` - Name *string `json:"name,omitempty"` - SizeInBytes *int64 `json:"size_in_bytes,omitempty"` - URL *string `json:"url,omitempty"` - ArchiveDownloadURL *string `json:"archive_download_url,omitempty"` - Expired *bool `json:"expired,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - ExpiresAt *Timestamp `json:"expires_at,omitempty"` - WorkflowRun *ArtifactWorkflowRun `json:"workflow_run,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + Name *string `json:"name,omitempty"` + SizeInBytes *int64 `json:"size_in_bytes,omitempty"` + URL *string `json:"url,omitempty"` + ArchiveDownloadURL *string `json:"archive_download_url,omitempty"` + Expired *bool `json:"expired,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + ExpiresAt *Timestamp `json:"expires_at,omitempty"` + // Digest is the SHA256 digest of the artifact. + // This field will only be populated on artifacts uploaded with upload-artifact v4 or newer. + // For older versions, this field will be null. + Digest *string `json:"digest,omitempty"` + WorkflowRun *ArtifactWorkflowRun `json:"workflow_run,omitempty"` } // ArtifactList represents a list of GitHub artifacts. diff --git a/github/github-accessors.go b/github/github-accessors.go index 2dc33c6a6aa..3b728d8d922 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -934,6 +934,14 @@ func (a *Artifact) GetCreatedAt() Timestamp { return *a.CreatedAt } +// GetDigest returns the Digest field if it's non-nil, zero value otherwise. +func (a *Artifact) GetDigest() string { + if a == nil || a.Digest == nil { + return "" + } + return *a.Digest +} + // GetExpired returns the Expired field if it's non-nil, zero value otherwise. func (a *Artifact) GetExpired() bool { if a == nil || a.Expired == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 6392c967f7c..62e7fa7a43d 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1205,6 +1205,17 @@ func TestArtifact_GetCreatedAt(tt *testing.T) { a.GetCreatedAt() } +func TestArtifact_GetDigest(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Artifact{Digest: &zeroValue} + a.GetDigest() + a = &Artifact{} + a.GetDigest() + a = nil + a.GetDigest() +} + func TestArtifact_GetExpired(tt *testing.T) { tt.Parallel() var zeroValue bool