Add return_run_details parameter to Workflow.create_dispatch by SebastienSyd · Pull Request #3471 · PyGithub/PyGithub · GitHub
Skip to content

Add return_run_details parameter to Workflow.create_dispatch#3471

Open
SebastienSyd wants to merge 1 commit into
PyGithub:mainfrom
SebastienSyd:add-workflow-dispatch-run-details
Open

Add return_run_details parameter to Workflow.create_dispatch#3471
SebastienSyd wants to merge 1 commit into
PyGithub:mainfrom
SebastienSyd:add-workflow-dispatch-run-details

Conversation

@SebastienSyd

@SebastienSyd SebastienSyd commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements support for GitHub's workflow dispatch return_run_details parameter (API version 2026-03-10) that returns immediate workflow run details when triggering a workflow dispatch event.

cf. doc here: https://docs.github.com/en/rest/actions/workflows?apiVersion=2026-03-10&versionId=free-pro-team%40latest&category=actions#create-a-workflow-dispatch-event

Changes

  • New Parameter: Added return_run_details boolean parameter to Workflow.create_dispatch() (default: False)
  • Return Type: When return_run_details=True, returns a WorkflowRun object instead of a boolean
  • Backward Compatible: Existing behavior unchanged when parameter is False (default)
  • Test Coverage: Added test case testCreateDispatchWithReturnRunDetails with replay data

Benefits

  • Immediate Access: Get workflow run details immediately without polling or searching
  • Better UX: Enable immediate access to methods like cancel(), rerun(), get_jobs() on the returned WorkflowRun object
  • API Alignment: Matches GitHub's latest Actions API capabilities

Example Usage

# Old behavior (still works)
success = workflow.create_dispatch(ref="main", inputs={})  # Returns bool

# New behavior with run details
run = workflow.create_dispatch(ref="main", inputs={}, return_run_details=True)
print(f"Workflow run ID: {run.id}")
print(f"View at: {run.html_url}")
run.cancel()  # Can immediately interact with the run

Test plan

  • Unit tests pass with new test case
  • Tested against live GitHub API (EnterpriseDB/poc repository)
  • Backward compatibility verified (default behavior unchanged)
  • Both throw=True and throw=False code paths tested

Implements support for GitHub's workflow dispatch `return_run_details` parameter (API version 2026-03-10) which returns immediate workflow run details when triggering a workflow dispatch event.

When `return_run_details=True`, the method now returns a `WorkflowRun` object containing `id`, `url`, and `html_url` of the triggered run, instead of a boolean. This enables immediate access to the run details without polling or searching, and allows calling methods like `cancel()`, `rerun()`, and `get_jobs()` on the returned object.

The feature maintains backward compatibility - when `return_run_details=False` (default), it continues to return a boolean as before.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@SebastienSyd SebastienSyd force-pushed the add-workflow-dispatch-run-details branch from dc4ce31 to 7a2a901 Compare March 24, 2026 16:47
@SebastienSyd

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant