()
| 493 | ) |
| 494 | |
| 495 | func (d *detector) ActionsFeatures() (ActionsFeatures, error) { |
| 496 | // TODO workflowDispatchRunDetailsCleanup |
| 497 | // Once GHES 3.20 support ends, we don't need feature detection for workflow dispatch (i.e. run details support). |
| 498 | // |
| 499 | // On github.com, workflow dispatch API now supports a new field named `return_run_details` that enabling it will |
| 500 | // result in a 200 OK response with the details of the created workflow run. If not set (or set to false), the API |
| 501 | // will keep the old behavior of returning a 204 No Content response. |
| 502 | // |
| 503 | // On GHES (current latest at 3.20), this new field is not available, and setting it will cause a 400 response. |
| 504 | // |
| 505 | // Once GHES 3.20 support ends, we can remove the feature detection and start using the new field in API calls. |
| 506 | // |
| 507 | // IMPORTANT: In the future REST API versions (i.e. breaking changes), the workflow dispatch endpoint is going to |
| 508 | // always return the details of the created workflow run in the response, and the `return_run_details` field is |
| 509 | // going to be ignored/removed. So, once we are migrating to the new API version we should double check the status |
| 510 | // of the API. |
| 511 | |
| 512 | if !ghauth.IsEnterprise(d.host) { |
| 513 | return ActionsFeatures{ |
| 514 | DispatchRunDetails: true, |
| 515 | }, nil |
| 516 | } |
| 517 | |
| 518 | minSupportedVersion, err := version.NewVersion(enterpriseWorkflowDispatchRunDetailsSupport) |
| 519 | if err != nil { |
| 520 | return ActionsFeatures{}, err |
| 521 | } |
| 522 | |
| 523 | hostVersion, err := resolveEnterpriseVersion(d.httpClient, d.host) |
| 524 | if err != nil { |
| 525 | return ActionsFeatures{}, err |
| 526 | } |
| 527 | |
| 528 | if hostVersion.GreaterThanOrEqual(minSupportedVersion) { |
| 529 | return ActionsFeatures{ |
| 530 | DispatchRunDetails: true, |
| 531 | }, nil |
| 532 | } |
| 533 | |
| 534 | return ActionsFeatures{ |
| 535 | DispatchRunDetails: false, |
| 536 | }, nil |
| 537 | } |
| 538 | |
| 539 | func resolveEnterpriseVersion(httpClient *http.Client, host string) (*version.Version, error) { |
| 540 | var metaResponse struct { |
nothing calls this directly
no test coverage detected