// Copyright 2020 The go-github AUTHORS. All rights reserved.//// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package githubimport ()// ArtifactWorkflowRun represents a GitHub artifact's workflow run.//// GitHub API docs: https://docs.github.com/rest/actions/artifactstypeArtifactWorkflowRunstruct { ID *int64`json:"id,omitempty"` RepositoryID *int64`json:"repository_id,omitempty"` HeadRepositoryID *int64`json:"head_repository_id,omitempty"` HeadBranch *string`json:"head_branch,omitempty"` HeadSHA *string`json:"head_sha,omitempty"`}// Artifact represents a GitHub artifact. Artifacts allow sharing// data between jobs in a workflow and provide storage for data// once a workflow is complete.//// GitHub API docs: https://docs.github.com/rest/actions/artifactstypeArtifactstruct { 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"`}// ArtifactList represents a list of GitHub artifacts.//// GitHub API docs: https://docs.github.com/rest/actions/artifacts#artifactstypeArtifactListstruct { TotalCount *int64`json:"total_count,omitempty"` Artifacts []*Artifact`json:"artifacts,omitempty"`}// ListArtifacts lists all artifacts that belong to a repository.//// GitHub API docs: https://docs.github.com/rest/actions/artifacts#list-artifacts-for-a-repository////meta:operation GET /repos/{owner}/{repo}/actions/artifactsfunc ( *ActionsService) ( context.Context, , string, *ListOptions) (*ArtifactList, *Response, error) { := fmt.Sprintf("repos/%v/%v/actions/artifacts", , ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, } := new(ArtifactList) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// ListWorkflowRunArtifacts lists all artifacts that belong to a workflow run.//// GitHub API docs: https://docs.github.com/rest/actions/artifacts#list-workflow-run-artifacts////meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifactsfunc ( *ActionsService) ( context.Context, , string, int64, *ListOptions) (*ArtifactList, *Response, error) { := fmt.Sprintf("repos/%v/%v/actions/runs/%v/artifacts", , , ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, } := new(ArtifactList) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// GetArtifact gets a specific artifact for a workflow run.//// GitHub API docs: https://docs.github.com/rest/actions/artifacts#get-an-artifact////meta:operation GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}func ( *ActionsService) ( context.Context, , string, int64) (*Artifact, *Response, error) { := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", , , ) , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, } := new(Artifact) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// DownloadArtifact gets a redirect URL to download an archive for a repository.//// GitHub API docs: https://docs.github.com/rest/actions/artifacts#download-an-artifact////meta:operation GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}func ( *ActionsService) ( context.Context, , string, int64, int) (*url.URL, *Response, error) { := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v/zip", , , ) , := .client.roundTripWithOptionalFollowRedirect(, , )if != nil {returnnil, nil, }defer .Body.Close()if .StatusCode != http.StatusFound {returnnil, newResponse(), fmt.Errorf("unexpected status code: %s", .Status) } , := url.Parse(.Header.Get("Location"))if != nil {returnnil, newResponse(), }return , newResponse(), nil}// DeleteArtifact deletes a workflow run artifact.//// GitHub API docs: https://docs.github.com/rest/actions/artifacts#delete-an-artifact////meta:operation DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}func ( *ActionsService) ( context.Context, , string, int64) (*Response, error) { := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", , , ) , := .client.NewRequest("DELETE", , nil)if != nil {returnnil, }return .client.Do(, , nil)}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.