()
| 524 | ) |
| 525 | |
| 526 | func (d *detector) ActionsFeatures() (ActionsFeatures, error) { |
| 527 | // TODO workflowDispatchRunDetailsCleanup |
| 528 | // Once GHES 3.20 support ends, we don't need feature detection for workflow dispatch (i.e. run details support). |
| 529 | // |
| 530 | // On github.com, workflow dispatch API now supports a new field named `return_run_details` that enabling it will |
| 531 | // result in a 200 OK response with the details of the created workflow run. If not set (or set to false), the API |
| 532 | // will keep the old behavior of returning a 204 No Content response. |
| 533 | // |
| 534 | // On GHES (current latest at 3.20), this new field is not available, and setting it will cause a 400 response. |
| 535 | // |
| 536 | // Once GHES 3.20 support ends, we can remove the feature detection and start using the new field in API calls. |
| 537 | // |
| 538 | // IMPORTANT: In the future REST API versions (i.e. breaking changes), the workflow dispatch endpoint is going to |
| 539 | // always return the details of the created workflow run in the response, and the `return_run_details` field is |
| 540 | // going to be ignored/removed. So, once we are migrating to the new API version we should double check the status |
| 541 | // of the API. |
| 542 | |
| 543 | if !ghauth.IsEnterprise(d.host) { |
| 544 | return ActionsFeatures{ |
| 545 | DispatchRunDetails: true, |
| 546 | }, nil |
| 547 | } |
| 548 | |
| 549 | minSupportedVersion, err := version.NewVersion(enterpriseWorkflowDispatchRunDetailsSupport) |
| 550 | if err != nil { |
| 551 | return ActionsFeatures{}, err |
| 552 | } |
| 553 | |
| 554 | hostVersion, err := resolveEnterpriseVersion(d.httpClient, d.host) |
| 555 | if err != nil { |
| 556 | return ActionsFeatures{}, err |
| 557 | } |
| 558 | |
| 559 | if hostVersion.GreaterThanOrEqual(minSupportedVersion) { |
| 560 | return ActionsFeatures{ |
| 561 | DispatchRunDetails: true, |
| 562 | }, nil |
| 563 | } |
| 564 | |
| 565 | return ActionsFeatures{ |
| 566 | DispatchRunDetails: false, |
| 567 | }, nil |
| 568 | } |
| 569 | |
| 570 | func resolveEnterpriseVersion(httpClient *http.Client, host string) (*version.Version, error) { |
| 571 | var metaResponse struct { |
nothing calls this directly
no test coverage detected