feat(api): return run info for dispatched workflows (#7193)

- When the API endpoint `/repos/{owner}/{repo}/actions/workflows/{workflowname}/dispatches` is used to launch a workflow, it currently returns no data; `/repos/{owner}/{repo}/actions/tasks` can be used to track the progress of a workflow, but you need at least that workflow's run_id and the quantity of its child jobs. Tracking workflow progress is especially important if you want to chain together multiple workflows that exist within different repositories, which is desired for https://codeberg.org/forgejo/forgejo/issues/6312.
- Make it possible to track the progress of manually triggered workflows by modifying the `/repos/{owner}/{repo}/actions/workflows/{workflowname}/dispatches` to return a JSON object containing the triggered workflow's id and a list of its child job names.

Co-authored-by: Andrii Chyrva <achyrva@amcbridge.com>
Co-authored-by: Andrii Chyrva <andrii.s.chyrva@hotmail.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7193
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: markturney <markturney@gmail.com>
Co-committed-by: markturney <markturney@gmail.com>
This commit is contained in:
markturney 2025-03-14 16:01:15 +00:00 committed by Gusted
parent c7cb5f9978
commit 7a19d3c2be
7 changed files with 88 additions and 13 deletions

View file

@ -12,4 +12,16 @@ type DispatchWorkflowOption struct {
Ref string `json:"ref"`
// Input keys and values configured in the workflow file.
Inputs map[string]string `json:"inputs"`
// Flag to return the run info
// default: false
ReturnRunInfo bool `json:"return_run_info"`
}
// DispatchWorkflowRun represents a workflow run
// swagger:model
type DispatchWorkflowRun struct {
// the workflow run id
ID int64 `json:"id"`
// the jobs name
Jobs []string `json:"jobs"`
}