Skip to content

WorkflowDispatch api optionally return runid#36706

Merged
lunny merged 7 commits intogo-gitea:mainfrom
ChristopherHX:dispatch-return-runid
Mar 1, 2026
Merged

WorkflowDispatch api optionally return runid#36706
lunny merged 7 commits intogo-gitea:mainfrom
ChristopherHX:dispatch-return-runid

Conversation

@ChristopherHX
Copy link
Copy Markdown
Contributor

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 22, 2026
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Feb 22, 2026
@ChristopherHX
Copy link
Copy Markdown
Contributor Author

swagger page now looks like this

image

@ChristopherHX ChristopherHX added type/enhancement An improvement of existing functionality topic/gitea-actions related to the actions of Gitea labels Feb 22, 2026
@silverwind silverwind requested a review from Copilot February 22, 2026 15:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the GitHub workflow dispatch API feature that optionally returns run details (workflow run ID and URLs) when dispatching a workflow. This matches the GitHub API behavior announced in their February 2026 changelog. The implementation adds an optional return_run_details query parameter that, when set to true, returns a 200 OK response with run details instead of the default 204 No Content response.

Changes:

  • Modified DispatchActionWorkflow service function to return the created workflow run ID
  • Updated API endpoint to optionally return run details based on return_run_details query parameter
  • Added RunDetails struct to define the response format with workflow run ID and URLs
  • Added comprehensive test coverage for the new functionality

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/actions/workflow.go Changed DispatchActionWorkflow to return (runID int64, workflowError error) instead of just error, updating all error returns to include a 0 runID
routers/api/v1/repo/action.go Added conditional response logic: returns 204 No Content by default, or 200 OK with run details when return_run_details=true
routers/web/repo/actions/view.go Updated caller to handle the new return signature by ignoring the returned runID
modules/structs/repo_actions.go Added RunDetails struct containing WorkflowRunID, RunURL, and HTMLURL fields
routers/api/v1/swagger/action.go Added Swagger response definition for RunDetails
templates/swagger/v1_json.tmpl Updated Swagger documentation with new query parameter and response definitions
tests/integration/actions_trigger_test.go Added test case to verify the new functionality works correctly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@silverwind silverwind added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 22, 2026
@silverwind
Copy link
Copy Markdown
Member

Comment written by Claude (AI assistant) on behalf of @silverwind


Nice feature! A few observations:

Consider reusing ActionWorkflowRun instead of a new RunDetails struct

The codebase already has ActionWorkflowRun (in modules/structs/repo_actions.go) and ToActionWorkflowRun (in services/convert/convert.go) which construct the full workflow run API response including id, url, html_url, and more. Instead of introducing a new RunDetails struct with different field names, could this endpoint just return the existing ActionWorkflowRun? That would be:

  • More consistent with other run-related API endpoints (e.g., GetWorkflowRun)
  • More useful for API consumers (they get status, event, head_sha, etc. without a second call)
  • Less new surface area to maintain

Field naming diverges from existing patterns

The new RunDetails struct uses workflow_run_id and run_url as JSON keys, while the existing ActionWorkflowRun struct uses id and url for the same concepts. This inconsistency could confuse API consumers. If a separate struct is preferred, aligning the field names with the existing convention (id, url, html_url) would be better.

Minor: named return value

The DispatchActionWorkflow signature change to (runID int64, workflowError error) - the named workflowError is a bit unusual. Plain error is more idiomatic Go unless naked returns are used (which they aren't here). Not a blocker, just a style note.

@ChristopherHX ChristopherHX removed the type/enhancement An improvement of existing functionality label Feb 22, 2026
@ChristopherHX
Copy link
Copy Markdown
Contributor Author

Consider reusing ActionWorkflowRun instead of a new RunDetails struct

The codebase already has ActionWorkflowRun (in modules/structs/repo_actions.go) and ToActionWorkflowRun (in services/convert/convert.go) which construct the full workflow run API response including id, url, html_url, and more. Instead of introducing a new RunDetails struct with different field names, could this endpoint just return the existing ActionWorkflowRun? That would be:

  • More consistent with other run-related API endpoints (e.g., GetWorkflowRun)
  • More useful for API consumers (they get status, event, head_sha, etc. without a second call)
  • Less new surface area to maintain

Field naming diverges from existing patterns

The new RunDetails struct uses workflow_run_id and run_url as JSON keys, while the existing ActionWorkflowRun struct uses id and url for the same concepts. This inconsistency could confuse API consumers. If a separate struct is preferred, aligning the field names with the existing convention (id, url, html_url) would be better.

Note, adding more fields is ok for me. However not following the GitHub Docs not. So I generally disagree to these points of claude

Minor: named return value

The DispatchActionWorkflow signature change to (runID int64, workflowError error) - the named workflowError is a bit unusual. Plain error is more idiomatic Go unless naked returns are used (which they aren't here). Not a blocker, just a style note.

I saw wxiaoguang using an anonymous struct with named fields, not sure if this is a better pattern.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 24, 2026
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented Mar 1, 2026

Minor: named return value
The DispatchActionWorkflow signature change to (runID int64, workflowError error) - the named workflowError is a bit unusual. Plain error is more idiomatic Go unless naked returns are used (which they aren't here). Not a blocker, just a style note.

I saw wxiaoguang using an anonymous struct with named fields, not sure if this is a better pattern.

Changed it to (runID int64, _ err)

Sometimes I use "anonymous struct" when the returned values are too many (more than 2 or 3)

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 1, 2026
@ChristopherHX
Copy link
Copy Markdown
Contributor Author

Thanks.

Sounds good, to give the error the discard identifier, since this is self explaining if not used. Never thought about this.

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 1, 2026
@lunny lunny added this to the 1.26.0 milestone Mar 1, 2026
@lunny lunny merged commit bc9817b into go-gitea:main Mar 1, 2026
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 1, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 2, 2026
* giteaofficial/main: (21 commits)
  Enable docker layer caching for `dry-run` and `nightly` container builds (go-gitea#36738)
  Add admin badge to navbar avatar (go-gitea#36790)
  WorkflowDispatch api optionally return runid (go-gitea#36706)
  upgrade minimatch (go-gitea#36760)
  Add `never` option to `PUBLIC_URL_DETECTION` configuration (go-gitea#36785)
  Refactor avatar package, support default avatar fallback (go-gitea#36788)
  Mark unused&immature activitypub as "not implemented" (go-gitea#36789)
  Add “Copy Source” to markup comment menu (go-gitea#36726)
  Update Nix flake (go-gitea#36787)
  Implements OIDC RP-Initiated Logout (go-gitea#36724)
  Fix README symlink resolution in subdirectories like .github (go-gitea#36775)
  [skip ci] Updated translations via Crowdin
  Correct spelling (go-gitea#36783)
  refactor: replace legacy tw-flex utility classes with flex-text-block/inline (go-gitea#36778)
  Fix `no-content` message not rendering after comment edit (go-gitea#36733)
  Fix typos and grammar in English locale (go-gitea#36751)
  Move Fomantic dropdown CSS to custom module (go-gitea#36530)
  Use "Enable Gravatar" but not "Disable" (go-gitea#36771)
  feat: add branch_count to repository API (go-gitea#35351) (go-gitea#36743)
  Deprecate RenderWithErr (go-gitea#36769)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code topic/gitea-actions related to the actions of Gitea type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants