Skip to content
Draft
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
34 changes: 34 additions & 0 deletions modules/structs/repo_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ type ActionWorkflowRun struct {
HeadRepository *Repository `json:"head_repository,omitempty"`
Conclusion string `json:"conclusion,omitempty"`
// swagger:strfmt date-time
CreatedAt time.Time `json:"created_at"`
// swagger:strfmt date-time
StartedAt time.Time `json:"started_at"`
// swagger:strfmt date-time
CompletedAt time.Time `json:"completed_at"`
Expand Down Expand Up @@ -226,3 +228,35 @@ type RunDetails struct {
RunURL string `json:"run_url"`
HTMLURL string `json:"html_url"`
}

// ActionLogCursor represents a cursor position within a step's log
type ActionLogCursor struct {
Step int `json:"step"`
Cursor int64 `json:"cursor"`
Expanded bool `json:"expanded"`
}

// ActionLogRequest is the request body for the streaming log endpoint
type ActionLogRequest struct {
LogCursors []ActionLogCursor `json:"logCursors"`
}

// ActionLogStepLine represents a single log line within a step
type ActionLogStepLine struct {
Index int64 `json:"index"`
Message string `json:"message"`
Timestamp float64 `json:"timestamp"`
}

// ActionLogStep represents log lines for a single step with cursor state
type ActionLogStep struct {
Step int `json:"step"`
Cursor int64 `json:"cursor"`
Lines []*ActionLogStepLine `json:"lines"`
Started int64 `json:"started"`
}

// ActionLogResponse is the response body for the streaming log endpoint
type ActionLogResponse struct {
StepsLog []*ActionLogStep `json:"stepsLog"`
}
15 changes: 12 additions & 3 deletions routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,17 @@ func Routes() *web.Router {
m.Delete("", reqToken(), reqRepoWriter(unit.TypeActions), repo.DeleteActionRun)
m.Post("/rerun", reqToken(), reqRepoWriter(unit.TypeActions), repo.RerunWorkflowRun)
m.Post("/rerun-failed-jobs", reqToken(), reqRepoWriter(unit.TypeActions), repo.RerunFailedWorkflowRun)
m.Get("/jobs", repo.ListWorkflowRunJobs)
m.Post("/jobs/{job_id}/rerun", reqToken(), reqRepoWriter(unit.TypeActions), repo.RerunWorkflowJob)
m.Post("/cancel", reqToken(), reqRepoWriter(unit.TypeActions), repo.CancelWorkflowRun)
m.Post("/approve", reqToken(), reqRepoWriter(unit.TypeActions), repo.ApproveWorkflowRun)
m.Group("/jobs", func() {
m.Get("", repo.ListWorkflowRunJobs)
m.Get("/{job_id}/logs", reqToken(), reqRepoReader(unit.TypeActions), repo.GetWorkflowJobLogs)
m.Post("/{job_id}/rerun", reqToken(), reqRepoWriter(unit.TypeActions), repo.RerunWorkflowJob)
})
m.Group("/logs", func() {
m.Get("", reqToken(), reqRepoReader(unit.TypeActions), repo.GetWorkflowRunLogs)
m.Post("", reqToken(), reqRepoReader(unit.TypeActions), repo.GetWorkflowRunLogsStream)
})
m.Get("/artifacts", repo.GetArtifactsOfRun)
})
})
Expand All @@ -1272,7 +1281,7 @@ func Routes() *web.Router {
m.Delete("", reqRepoWriter(unit.TypeActions), repo.DeleteArtifact)
})
m.Get("/artifacts/{artifact_id}/zip", repo.DownloadArtifact)
}, reqRepoReader(unit.TypeActions))
}, reqRepoReader(unit.TypeActions), context.ReferencesGitRepo(true))
m.Group("/keys", func() {
m.Combo("").Get(repo.ListDeployKeys).
Post(bind(api.CreateKeyOption{}), repo.CreateDeployKey)
Expand Down
6 changes: 3 additions & 3 deletions routers/api/v1/repo/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ func GetWorkflowRun(ctx *context.APIContext) {
return
}

convertedRun, err := convert.ToActionWorkflowRun(ctx, run, nil)
convertedRun, err := convert.ToActionWorkflowRun(ctx, ctx.Repo.Repository, run, nil)
if err != nil {
ctx.APIErrorInternal(err)
return
Expand Down Expand Up @@ -1282,7 +1282,7 @@ func GetWorkflowRunAttempt(ctx *context.APIContext) {
return
}

convertedRun, err := convert.ToActionWorkflowRun(ctx, run, attempt)
convertedRun, err := convert.ToActionWorkflowRun(ctx, ctx.Repo.Repository, run, attempt)
if err != nil {
ctx.APIErrorInternal(err)
return
Expand Down Expand Up @@ -1337,7 +1337,7 @@ func RerunWorkflowRun(ctx *context.APIContext) {
return
}

convertedRun, err := convert.ToActionWorkflowRun(ctx, run, nil)
convertedRun, err := convert.ToActionWorkflowRun(ctx, ctx.Repo.Repository, run, nil)
if err != nil {
ctx.APIErrorInternal(err)
return
Expand Down
Loading