Skip to main content

workflow_dispatch_path_segment

Function workflow_dispatch_path_segment 

Source
pub fn workflow_dispatch_path_segment(name: &str) -> Option<String>
Expand description

Normalize a user-facing workflow identifier into the path segment GitHub’s workflow_dispatch endpoint expects as {workflow_file_name} in /repos/{owner}/{repo}/actions/workflows/{workflow_file_name}/dispatches.

  • Drops any directory prefix: "release/prod.yml""prod.yml".
  • Preserves an existing .yml or .yaml suffix so workflows stored as .yaml don’t have .yml tacked on.
  • Appends .yml when no extension is present so the result is always a valid filename reference.
  • Returns None for inputs with no extractable basename (empty string, bare path separator, trailing slash).

Used both by trigger_workflow to build the real dispatch URL and by the TUI’s Trigger-tab curl preview via this crate’s public API, so the preview and the actual POST land on the same endpoint.