Skip to content

feat: add github_enterprise_actions_hosted_runner#3017

Open
nico34638 wants to merge 6 commits intointegrations:mainfrom
nico34638:main
Open

feat: add github_enterprise_actions_hosted_runner#3017
nico34638 wants to merge 6 commits intointegrations:mainfrom
nico34638:main

Conversation

@nico34638
Copy link
Copy Markdown

@nico34638 nico34638 commented Dec 22, 2025

Resolves #3016


Before the change?

  • No possibility to create hosted runner at enterprise level

After the change?

  • It's possible

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@deiga
Copy link
Copy Markdown
Collaborator

deiga commented Dec 24, 2025

Hey @nico34638 👋

Thank you very much for your contribution! We're currently working on a major release of the provider and that will possibly delay getting this PR merged.

While that's happening, could I bother you for a few changes?

  • We're moving towards using Context-aware provider functions (ReadContext, CreateContext, etc.). Could you refactor your PR to use those? :)
  • Another major upcoming change will be generating docs based on Schema contents. Could you ensure that all levels of the Schema have Description fields which contain all necessary information for the docs?

Support for Hosted runners for enterprises was added in v70 of go-github. Our upcoming major release will upgrade to v77. Could you rebase your branch on top of #2891 and use the SDK methods instead of manual HTTP requests? :)

@nico34638
Copy link
Copy Markdown
Author

Okay, I made the changes you requested. I rebased on your branch with go github/v77 and changed the description fields. Is that okay with you? I tested it, and with the changes, it still works.

@deiga
Copy link
Copy Markdown
Collaborator

deiga commented Jan 9, 2026

Hey @nico34638
Could you rebase your PR onto main now, we've upgraded the go-github version? 🙏

@nico34638
Copy link
Copy Markdown
Author

Hey @deiga, It's done. Do you have any idea when the provider's next release will be?

Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner_test.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner_test.go Outdated
Comment thread website/docs/r/enterprise_actions_hosted_runner.html.markdown Outdated
Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

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

Please ensure the test structure follows the current pattern

Comment thread github/resource_github_enterprise_actions_hosted_runner_test.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner_test.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner_test.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
@nico34638 nico34638 force-pushed the main branch 3 times, most recently from 36951d4 to 9ac9b53 Compare January 17, 2026 14:27
@nico34638
Copy link
Copy Markdown
Author

I have corrected the comments

@nico34638
Copy link
Copy Markdown
Author

Hi @deiga do you any news ?

@deiga deiga added this to the v6.11.0 Release milestone Jan 21, 2026
@deiga deiga added Type: Feature New feature or request New resource labels Jan 21, 2026
Copy link
Copy Markdown
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @nico34638, I've added some initial review comments.

Comment thread github/resource_github_enterprise_actions_hosted_runner.go
Comment thread website/docs/r/enterprise_actions_hosted_runner.html.markdown
Comment thread github/util_runners.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner_test.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
@nico34638
Copy link
Copy Markdown
Author

Following the last review, I'm taking this opportunity to add two data sources for hosted enterprise runners:
one to list them and one to get the details.

@nico34638
Copy link
Copy Markdown
Author

Hi @stevehipwell @deiga Do you have any news ?

Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

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

Please ensure to propagate comments to other places where they would be applicable

Comment thread github/data_source_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/data_source_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/data_source_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/data_source_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/data_source_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread website/docs/r/enterprise_actions_hosted_runner.html.markdown
@nico34638 nico34638 force-pushed the main branch 3 times, most recently from 06b9a9c to 54d4fbe Compare February 14, 2026 13:19
Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

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

Please read through your own code and see to it that it's consistent with itself.

I don't know if you use an LLM to generate code or are just in a hurry, but please don't make us comment multiple times on the same issues ☺️

@nico34638
Copy link
Copy Markdown
Author

Thanks for the feedback. I apologize for the inconsistencies.

I am really trying my best to keep this PR clean, but it is not that simple. Reviews are spaced about many weeks apart. It is hard to keep track of comments made two months ago.

The requirements also keep changing mid-flight. For example, we now need datasources in addition to resources to get merged. On top of that, the codebase is being refactored.

I have reviewed the code again and updated a few more details on my end. However, I would really appreciate more specific information on what exactly still needs to change

Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

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

Partial review

Comment thread github/resource_github_enterprise_actions_hosted_runner.go Outdated
Comment thread github/data_source_github_enterprise_actions_hosted_runner_test.go Outdated
Comment thread website/docs/r/enterprise_actions_hosted_runner.html.markdown Outdated
Comment thread github/data_source_github_enterprise_actions_hosted_runner_test.go Outdated
Comment thread github/data_source_github_enterprise_actions_hosted_runner_test.go
Comment thread github/data_source_github_enterprise_actions_hosted_runners.go Outdated
"size": {
Type: schema.TypeString,
Required: true,
Description: "Machine size for the hosted runner (e.g., '4-core', '8-core'). This determines the CPU, memory, and storage resources allocated to the runner. Can be updated to scale the runner. To list available sizes, use the GitHub API: GET /enterprises/{enterprise}/actions/hosted-runners/machine-sizes.",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

question: would this benefit from having a validation that the string ends in <number>-core?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't think that's necessary, the API error is already clear.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But validation happens before API call, which means less wasted rate limit usage

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I had regex validation

@nico34638 nico34638 force-pushed the main branch 2 times, most recently from faa7c93 to 4572819 Compare March 17, 2026 13:58
Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

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

Partial review

`, testAccConf.enterpriseSlug, testResourcePrefix, randomID, testResourcePrefix, randomID)

resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessMode(t, enterprise) },
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
PreCheck: func() { skipUnlessMode(t, enterprise) },
PreCheck: func() { skipUnlessEnterprise(t) },


func dataSourceGithubEnterpriseActionsHostedRunner() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceGithubEnterpriseActionsHostedRunnerRead,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add a top-level Description

Comment on lines +172 to +192
runnerData := map[string]any{
"name": runner.GetName(),
"runner_group_id": int(runner.GetRunnerGroupID()),
"platform": runner.GetPlatform(),
"status": runner.GetStatus(),
"maximum_runners": int(runner.GetMaximumRunners()),
"public_ip_enabled": runner.GetPublicIPEnabled(),
"image_details": flattenHostedRunnerImage(runner.ImageDetails),
"machine_size_details": flattenHostedRunnerMachineSpec(runner.MachineSizeDetails),
"public_ips": flattenHostedRunnerPublicIPs(runner.PublicIPs),
}

if runner.LastActiveOn != nil {
runnerData["last_active_on"] = runner.LastActiveOn.Format(time.RFC3339)
}

for k, v := range runnerData {
if err := d.Set(k, v); err != nil {
return diag.FromErr(err)
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: Please simplify this structure to just use d.Set without this map. This does not improve clarity, nor does it win us anything


func dataSourceGithubEnterpriseActionsHostedRunners() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceGithubEnterpriseActionsHostedRunnersRead,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add a top-level Description

Delete: schema.DefaultTimeout(15 * time.Minute),
},

Schema: map[string]*schema.Schema{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add a top-level Description

return diag.Errorf("error updating enterprise hosted runner: %s", err.Error())
}

return resourceGithubEnterpriseActionsHostedRunnerRead(ctx, d, meta)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Never call any CRUD functions in any part of the code

Suggested change
return resourceGithubEnterpriseActionsHostedRunnerRead(ctx, d, meta)
return nil

Comment on lines +433 to +441
enterpriseSlug, runnerIDStr, err := parseID2(d.Id())
if err != nil {
return diag.FromErr(err)
}

runnerID, err := strconv.ParseInt(runnerIDStr, 10, 64)
if err != nil {
return diag.Errorf("invalid runner ID %q: %s", runnerIDStr, err.Error())
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: both fields exists in State already, there should be no need to have parsing code here

}
`, testAccConf.enterpriseSlug, randomID, randomID)

configUpdated := fmt.Sprintf(`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use only one template string and fmt.Sprintf to build the config

Comment thread github/util_runners.go
return nil
}

imageMap := imageList[0].(map[string]any)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add some explanation why we are only accessing the first item.

Comment thread github/util_runners.go
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These functions are missing tests, please add them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New resource Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: enterprise_actions_hosted_runner

3 participants