Skip to content

Artifacts download api for artifact actions v4 #33510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
32b6aef
Artifacts download api for artifact actions v4
ChristopherHX Feb 5, 2025
f7a1dca
Update swagger docs
ChristopherHX Feb 5, 2025
3f0cafd
fix swagger
ChristopherHX Feb 5, 2025
ef5b069
format code
ChristopherHX Feb 5, 2025
26514c9
use MakeAbsoluteURL
ChristopherHX Feb 5, 2025
e7308ac
fix lint? swagger command defect?
ChristopherHX Feb 5, 2025
e129fe8
revert encoding /
ChristopherHX Feb 5, 2025
d5520bd
302 => http.StatusFound
ChristopherHX Feb 5, 2025
d3dbfcb
extract getArtifactByID into a helper function
ChristopherHX Feb 5, 2025
d50358f
move old and new logic to modules
ChristopherHX Feb 5, 2025
bbb7017
fixup
ChristopherHX Feb 5, 2025
fcb8d55
intial tests
ChristopherHX Feb 5, 2025
db619c3
use correct json lib
ChristopherHX Feb 5, 2025
f4b0811
use http.ServeContent
ChristopherHX Feb 5, 2025
c6f1557
fix tests
ChristopherHX Feb 5, 2025
dfae484
use MakeAbsoluteURL
ChristopherHX Feb 5, 2025
ae2202d
add copyright header
ChristopherHX Feb 5, 2025
b4c318c
more tests fix old type from my side
ChristopherHX Feb 5, 2025
5e3c79d
fmt code
ChristopherHX Feb 5, 2025
b1b0ef3
add DeleteArtifact api
ChristopherHX Feb 6, 2025
e1ce404
Merge branch 'main' of https://github.com/go-gitea/gitea into artifac…
ChristopherHX Feb 9, 2025
59cf964
fix some swagger docu issues
ChristopherHX Feb 9, 2025
4721100
use repository apiurl method
ChristopherHX Feb 9, 2025
7a35443
remove unused ctx
ChristopherHX Feb 10, 2025
e137972
Merge branch 'main' into artifacts-download-api
ChristopherHX Feb 10, 2025
44bde87
fix merge
ChristopherHX Feb 10, 2025
a18c8dd
fix private repository artifact download redirect
ChristopherHX Feb 10, 2025
f8ce2f6
fmt
ChristopherHX Feb 10, 2025
5b76dbe
fix import
ChristopherHX Feb 10, 2025
6009e63
Merge branch 'main' into artifacts-download-api
silverwind Feb 11, 2025
8485044
add download test for private repo and remove the token to the redirect
ChristopherHX Feb 11, 2025
f58f33d
Merge branch 'main' into artifacts-download-api
wxiaoguang Feb 13, 2025
d56cebf
refactor path parm & error handling
wxiaoguang Feb 15, 2025
ee37003
fix type casting
wxiaoguang Feb 15, 2025
5d7bf81
refactor getArtifactByPathParam
wxiaoguang Feb 15, 2025
3d1b156
refactor build endpoint
wxiaoguang Feb 15, 2025
e6629fc
remove repoAssignment for raw endpoint
wxiaoguang Feb 15, 2025
7861808
fix test
wxiaoguang Feb 15, 2025
8e48777
fix comment
wxiaoguang Feb 15, 2025
421b7b4
remove TestActionsArtifactV4DownloadRawArtifactMismatchedRepoOwnerMis…
ChristopherHX Feb 15, 2025
a00f7f8
Update test comments and names to reflect only repo check
ChristopherHX Feb 15, 2025
156f0db
use unix timestamp in sig
ChristopherHX Feb 15, 2025
3df911a
fix comment
ChristopherHX Feb 15, 2025
4c1399d
revert owner_id changes to reflect only repoid check
ChristopherHX Feb 15, 2025
a0ed53d
Update routers/api/v1/repo/action.go
wxiaoguang Feb 15, 2025
12c627a
Merge branch 'main' into artifacts-download-api
wxiaoguang Feb 15, 2025
f80f4d1
Merge branch 'main' into artifacts-download-api
GiteaBot Feb 15, 2025
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
13 changes: 9 additions & 4 deletions models/actions/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ func UpdateArtifactByID(ctx context.Context, id int64, art *ActionArtifact) erro

type FindArtifactsOptions struct {
db.ListOptions
RepoID int64
RunID int64
ArtifactName string
Status int
RepoID int64
RunID int64
ArtifactName string
Status int
FinalizedArtifactsV2 bool
}

func (opts FindArtifactsOptions) ToConds() builder.Cond {
Expand All @@ -128,6 +129,10 @@ func (opts FindArtifactsOptions) ToConds() builder.Cond {
if opts.Status > 0 {
cond = cond.And(builder.Eq{"status": opts.Status})
}
if opts.FinalizedArtifactsV2 {
cond = cond.And(builder.Eq{"status": ArtifactStatusUploadConfirmed}.Or(builder.Eq{"status": ArtifactStatusExpired}))
cond = cond.And(builder.Eq{"content_encoding": "application/zip"})
}

return cond
}
Expand Down
31 changes: 31 additions & 0 deletions modules/structs/repo_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,34 @@ type ActionTaskResponse struct {
Entries []*ActionTask `json:"workflow_runs"`
TotalCount int64 `json:"total_count"`
}

// ActionArtifact represents a ActionArtifact
type ActionArtifact struct {
ID int64 `json:"id"`
Name string `json:"name"`
SizeInBytes int64 `json:"size_in_bytes"`
URL string `json:"url"`
ArchiveDownloadURL string `json:"archive_download_url"`
Expired bool `json:"expired"`
WorkflowRun *ActionWorkflowRun `json:"workflow_run"`

// swagger:strfmt date-time
CreatedAt time.Time `json:"created_at"`
// swagger:strfmt date-time
UpdatedAt time.Time `json:"updated_at"`
// swagger:strfmt date-time
ExpiresAt time.Time `json:"expires_at"`
}

// ActionWorkflowRun represents a WorkflowRun
type ActionWorkflowRun struct {
ID int64 `json:"id"`
RepositoryID int64 `json:"repository_id"`
HeadSha string `json:"head_sha"`
}

// ActionArtifactsResponse returns ActionArtifacts
type ActionArtifactsResponse struct {
Entries []*ActionArtifact `json:"artifacts"`
TotalCount int64 `json:"total_count"`
}
5 changes: 5 additions & 0 deletions routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,11 @@ func Routes() *web.Router {
}, reqToken(), reqAdmin())
m.Group("/actions", func() {
m.Get("/tasks", repo.ListActionTasks)
m.Get("/runs/{run}/artifacts", repo.GetArtifactsOfRun)
m.Get("/artifacts", repo.GetArtifacts)
m.Get("/artifacts/{artifact_id}", repo.GetArtifact)
m.Get("/artifacts/{artifact_id}/zip", repo.DownloadArtifact)
m.Get("/artifacts/{artifact_id}/zip/raw", repo.DownloadArtifactRaw)
}, reqRepoReader(unit.TypeActions), context.ReferencesGitRepo(true))
m.Group("/keys", func() {
m.Combo("").Get(repo.ListDeployKeys).
Expand Down
Loading