ParseRunURLExtended is similar to ParseRunURL but returns additional information including job ID and step details from deep URLs.
(input string)
| 287 | // ParseRunURLExtended is similar to ParseRunURL but returns additional information |
| 288 | // including job ID and step details from deep URLs. |
| 289 | func ParseRunURLExtended(input string) (*GitHubURLComponents, error) { |
| 290 | // First try to parse as a direct numeric ID |
| 291 | if runID, err := strconv.ParseInt(input, 10, 64); err == nil { |
| 292 | return &GitHubURLComponents{ |
| 293 | Type: URLTypeRun, |
| 294 | Number: runID, |
| 295 | }, nil |
| 296 | } |
| 297 | |
| 298 | // Try to parse as a GitHub URL |
| 299 | components, err := ParseGitHubURL(input) |
| 300 | if err != nil { |
| 301 | return nil, fmt.Errorf("invalid run ID or URL '%s': must be a numeric run ID or a GitHub URL containing '/actions/runs/{run-id}' or '/runs/{run-id}'", input) |
| 302 | } |
| 303 | |
| 304 | if components.Type != URLTypeRun { |
| 305 | return nil, errors.New("URL is not a GitHub Actions run URL") |
| 306 | } |
| 307 | |
| 308 | return components, nil |
| 309 | } |
| 310 | |
| 311 | // ParsePRURL is a convenience function that parses a GitHub PR URL and extracts PR information. |
| 312 | // Expected format: https://github.com/owner/repo/pull/123 or https://github.enterprise.com/owner/repo/pull/123 |