Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions github/actions_hosted_runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type HostedRunner struct {
Name *string `json:"name,omitempty"`
RunnerGroupID *int64 `json:"runner_group_id,omitempty"`
Platform *string `json:"platform,omitempty"`
ImageDetails *HostedRunnerImageDetail `json:"image_details,omitempty"`
Image *HostedRunnerImageDetail `json:"image,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://docs.github.com/en/rest/actions/hosted-runners?apiVersion=2022-11-28#list-github-hosted-runners-for-an-organization, HostedRunner contains the image_details field and not image.

Currently, the library uses 2022-11-28 API version:

defaultAPIVersion = "2022-11-28"

This PR should be done as part of #4077

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even on 2026-03-10 API Version it mentioned image_details and size_gb in response schema.
or I am missing something?

Screenshot 2026-03-18 at 6 54 53 PM

https://docs.github.com/en/rest/actions/hosted-runners?apiVersion=2026-03-10#list-github-hosted-runners-for-an-organization

MachineSizeDetails *HostedRunnerMachineSpec `json:"machine_size_details,omitempty"`
Status *string `json:"status,omitempty"`
MaximumRunners *int64 `json:"maximum_runners,omitempty"`
Expand All @@ -44,7 +44,7 @@ type HostedRunner struct {
// HostedRunnerImageDetail represents the image details of a GitHub-hosted runners.
type HostedRunnerImageDetail struct {
ID *string `json:"id"` // The ID of the image. Use this ID for the `image` parameter when creating a new larger runner. Example: ubuntu-20.04
SizeGB *int64 `json:"size_gb"` // Image size in GB. Example: 86
Size *int64 `json:"size"` // Image size in GB. Example: 86
DisplayName *string `json:"display_name"` // Display name for this image. Example: 20.04
Source *string `json:"source"` // The image provider. Example: github, partner, custom
Version *string `json:"version"` // The image version of the hosted runner pool. Example: latest
Expand Down
60 changes: 30 additions & 30 deletions github/actions_hosted_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
"name": "My hosted ubuntu runner",
"runner_group_id": 2,
"platform": "linux-x64",
"image_details": {
"image": {
"id": "ubuntu-20.04",
"size_gb": 86
"size": 86
},
"machine_size_details": {
"id": "4-core",
Expand All @@ -55,9 +55,9 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
"name": "My hosted Windows runner",
"runner_group_id": 2,
"platform": "win-x64",
"image_details": {
"image": {
"id": "windows-latest",
"size_gb": 256
"size": 256
},
"machine_size_details": {
"id": "8-core",
Expand Down Expand Up @@ -91,9 +91,9 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
Name: Ptr("My hosted ubuntu runner"),
RunnerGroupID: Ptr(int64(2)),
Platform: Ptr("linux-x64"),
ImageDetails: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
SizeGB: Ptr(int64(86)),
Image: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
Size: Ptr(int64(86)),
},
MachineSizeDetails: &HostedRunnerMachineSpec{
ID: "4-core",
Expand All @@ -118,9 +118,9 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
Name: Ptr("My hosted Windows runner"),
RunnerGroupID: Ptr(int64(2)),
Platform: Ptr("win-x64"),
ImageDetails: &HostedRunnerImageDetail{
ID: Ptr("windows-latest"),
SizeGB: Ptr(int64(256)),
Image: &HostedRunnerImageDetail{
ID: Ptr("windows-latest"),
Size: Ptr(int64(256)),
},
MachineSizeDetails: &HostedRunnerMachineSpec{
ID: "8-core",
Expand Down Expand Up @@ -166,9 +166,9 @@ func TestActionsService_CreateHostedRunner(t *testing.T) {
"name": "My hosted ubuntu runner",
"runner_group_id": 2,
"platform": "linux-x64",
"image_details": {
"image": {
"id": "ubuntu-20.04",
"size_gb": 86
"size": 86
},
"machine_size_details": {
"id": "4-core",
Expand Down Expand Up @@ -215,9 +215,9 @@ func TestActionsService_CreateHostedRunner(t *testing.T) {
Name: Ptr("My hosted ubuntu runner"),
RunnerGroupID: Ptr(int64(2)),
Platform: Ptr("linux-x64"),
ImageDetails: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
SizeGB: Ptr(int64(86)),
Image: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
Size: Ptr(int64(86)),
},
MachineSizeDetails: &HostedRunnerMachineSpec{
ID: "4-core",
Expand Down Expand Up @@ -617,9 +617,9 @@ func TestActionsService_GetHostedRunner(t *testing.T) {
"name": "My hosted ubuntu runner",
"runner_group_id": 2,
"platform": "linux-x64",
"image_details": {
"image": {
"id": "ubuntu-20.04",
"size_gb": 86
"size": 86
},
"machine_size_details": {
"id": "4-core",
Expand Down Expand Up @@ -653,9 +653,9 @@ func TestActionsService_GetHostedRunner(t *testing.T) {
Name: Ptr("My hosted ubuntu runner"),
RunnerGroupID: Ptr(int64(2)),
Platform: Ptr("linux-x64"),
ImageDetails: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
SizeGB: Ptr(int64(86)),
Image: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
Size: Ptr(int64(86)),
},
MachineSizeDetails: &HostedRunnerMachineSpec{
ID: "4-core",
Expand Down Expand Up @@ -706,9 +706,9 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) {
"name": "My hosted ubuntu runner",
"runner_group_id": 2,
"platform": "linux-x64",
"image_details": {
"image": {
"id": "ubuntu-20.04",
"size_gb": 86
"size": 86
},
"machine_size_details": {
"id": "4-core",
Expand Down Expand Up @@ -749,9 +749,9 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) {
Name: Ptr("My hosted ubuntu runner"),
RunnerGroupID: Ptr(int64(2)),
Platform: Ptr("linux-x64"),
ImageDetails: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
SizeGB: Ptr(int64(86)),
Image: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
Size: Ptr(int64(86)),
},
MachineSizeDetails: &HostedRunnerMachineSpec{
ID: "4-core",
Expand Down Expand Up @@ -843,9 +843,9 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) {
"name": "My hosted ubuntu runner",
"runner_group_id": 2,
"platform": "linux-x64",
"image_details": {
"image": {
"id": "ubuntu-20.04",
"size_gb": 86
"size": 86
},
"machine_size_details": {
"id": "4-core",
Expand Down Expand Up @@ -879,9 +879,9 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) {
Name: Ptr("My hosted ubuntu runner"),
RunnerGroupID: Ptr(int64(2)),
Platform: Ptr("linux-x64"),
ImageDetails: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
SizeGB: Ptr(int64(86)),
Image: &HostedRunnerImageDetail{
ID: Ptr("ubuntu-20.04"),
Size: Ptr(int64(86)),
},
MachineSizeDetails: &HostedRunnerMachineSpec{
ID: "4-core",
Expand Down
5 changes: 5 additions & 0 deletions github/actions_runner_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type RunnerGroup struct {
Default *bool `json:"default,omitempty"`
SelectedRepositoriesURL *string `json:"selected_repositories_url,omitempty"`
RunnersURL *string `json:"runners_url,omitempty"`
HostedRunnersURL *string `json:"hosted_runners_url,omitempty"`
NetworkConfigurationID *string `json:"network_configuration_id,omitempty"`
Inherited *bool `json:"inherited,omitempty"`
AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
RestrictedToWorkflows *bool `json:"restricted_to_workflows,omitempty"`
Expand Down Expand Up @@ -45,6 +47,8 @@ type CreateRunnerGroupRequest struct {
RestrictedToWorkflows *bool `json:"restricted_to_workflows,omitempty"`
// List of workflows the runner group should be allowed to run. This setting will be ignored unless RestrictedToWorkflows is set to true.
SelectedWorkflows []string `json:"selected_workflows,omitempty"`
// The identifier of a hosted compute network configuration.
NetworkConfigurationID *string `json:"network_configuration_id,omitempty"`
}

// UpdateRunnerGroupRequest represents a request to update a Runner group for an organization.
Expand All @@ -54,6 +58,7 @@ type UpdateRunnerGroupRequest struct {
AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
RestrictedToWorkflows *bool `json:"restricted_to_workflows,omitempty"`
SelectedWorkflows []string `json:"selected_workflows,omitempty"`
NetworkConfigurationID *string `json:"network_configuration_id,omitempty"`
}

// SetRepoAccessRunnerGroupRequest represents a request to replace the list of repositories
Expand Down
30 changes: 25 additions & 5 deletions github/actions_runner_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestActionsService_GetOrganizationRunnerGroup(t *testing.T) {

mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`)
fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","hosted_runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners","network_configuration_id":"EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`)
})

ctx := t.Context()
Expand All @@ -123,6 +123,8 @@ func TestActionsService_GetOrganizationRunnerGroup(t *testing.T) {
Default: Ptr(false),
SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"),
RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"),
HostedRunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"),
NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"),
Inherited: Ptr(false),
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(false),
Expand Down Expand Up @@ -179,7 +181,7 @@ func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) {

mux.HandleFunc("/orgs/o/actions/runner-groups", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`)
fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","hosted_runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners","network_configuration_id":"EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`)
})

ctx := t.Context()
Expand All @@ -189,6 +191,7 @@ func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) {
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(false),
SelectedWorkflows: []string{},
NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"),
}
group, _, err := client.Actions.CreateOrganizationRunnerGroup(ctx, "o", req)
if err != nil {
Expand All @@ -202,6 +205,8 @@ func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) {
Default: Ptr(false),
SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"),
RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"),
HostedRunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"),
NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"),
Inherited: Ptr(false),
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(false),
Expand Down Expand Up @@ -233,7 +238,7 @@ func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) {

mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`)
fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","hosted_runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners","network_configuration_id":"EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`)
})

ctx := t.Context()
Expand All @@ -243,6 +248,7 @@ func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) {
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(false),
SelectedWorkflows: []string{},
NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"),
}
group, _, err := client.Actions.UpdateOrganizationRunnerGroup(ctx, "o", 2, req)
if err != nil {
Expand All @@ -256,6 +262,8 @@ func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) {
Default: Ptr(false),
SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"),
RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"),
HostedRunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"),
NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"),
Inherited: Ptr(false),
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(false),
Expand Down Expand Up @@ -541,6 +549,8 @@ func TestRunnerGroup_Marshal(t *testing.T) {
Default: Ptr(true),
SelectedRepositoriesURL: Ptr("s"),
RunnersURL: Ptr("r"),
HostedRunnersURL: Ptr("h"),
NetworkConfigurationID: Ptr("nc"),
Inherited: Ptr(true),
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(false),
Expand All @@ -554,6 +564,8 @@ func TestRunnerGroup_Marshal(t *testing.T) {
"default": true,
"selected_repositories_url": "s",
"runners_url": "r",
"hosted_runners_url": "h",
"network_configuration_id": "nc",
"inherited": true,
"allows_public_repositories": true,
"restricted_to_workflows": false,
Expand All @@ -577,6 +589,8 @@ func TestRunnerGroups_Marshal(t *testing.T) {
Default: Ptr(true),
SelectedRepositoriesURL: Ptr("s"),
RunnersURL: Ptr("r"),
HostedRunnersURL: Ptr("h"),
NetworkConfigurationID: Ptr("nc"),
Inherited: Ptr(true),
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(false),
Expand All @@ -594,6 +608,8 @@ func TestRunnerGroups_Marshal(t *testing.T) {
"default": true,
"selected_repositories_url": "s",
"runners_url": "r",
"hosted_runners_url": "h",
"network_configuration_id": "nc",
"inherited": true,
"allows_public_repositories": true,
"restricted_to_workflows": false,
Expand All @@ -616,6 +632,7 @@ func TestCreateRunnerGroupRequest_Marshal(t *testing.T) {
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(true),
SelectedWorkflows: []string{"a", "b"},
NetworkConfigurationID: Ptr("nc"),
}

want := `{
Expand All @@ -625,7 +642,8 @@ func TestCreateRunnerGroupRequest_Marshal(t *testing.T) {
"runners": [1],
"allows_public_repositories": true,
"restricted_to_workflows": true,
"selected_workflows": ["a","b"]
"selected_workflows": ["a","b"],
"network_configuration_id": "nc"
}`

testJSONMarshal(t, u, want)
Expand All @@ -641,14 +659,16 @@ func TestUpdateRunnerGroupRequest_Marshal(t *testing.T) {
AllowsPublicRepositories: Ptr(true),
RestrictedToWorkflows: Ptr(false),
SelectedWorkflows: []string{},
NetworkConfigurationID: Ptr("nc"),
}

want := `{
"name": "n",
"visibility": "v",
"allows_public_repositories": true,
"restricted_to_workflows": false,
"selected_workflows": []
"selected_workflows": [],
"network_configuration_id": "nc"
}`

testJSONMarshal(t, u, want)
Expand Down
Loading