Skip to content

Add public field to repository pages#2540

Open
BartolottiLuca wants to merge 22 commits intointegrations:mainfrom
BartolottiLuca:repository-page-visibility
Open

Add public field to repository pages#2540
BartolottiLuca wants to merge 22 commits intointegrations:mainfrom
BartolottiLuca:repository-page-visibility

Conversation

@BartolottiLuca
Copy link

@BartolottiLuca BartolottiLuca commented Jan 17, 2025

Resolves #1045


Before the change?

  • Pages availability is not configurable via terraform

After the change?

  • Pages availability can now be configured via terraform via the public field

Pull request checklist

  • 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

Co-authored-by: Usman <akeju00+github@gmail.com>
@nickfloyd nickfloyd moved this from 🆕 Triage to 👀 In review in 🧰 Octokit Active Feb 27, 2025
@cyberkni
Copy link

I'd really like to have this feature available! Please!

@github-project-automation github-project-automation bot moved this from 👀 In review to 🏗 In progress in 🧰 Octokit Active Dec 5, 2025
@deiga
Copy link
Collaborator

deiga commented Jan 13, 2026

@BartolottiLuca Please rebase your PR :)

@BartolottiLuca
Copy link
Author

@deiga Thanks for the review, I've applied your suggestions and rebased

Comment on lines 1350 to 1360
t.Run("with an anonymous account", func(t *testing.T) {
t.Skip("anonymous account not supported for this feature")
})

t.Run("with an individual account", func(t *testing.T) {
t.Skip("individual account not supported for this feature")
})

t.Run("with an organization account", func(t *testing.T) {
testCase(t, organization)
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't use this structure anymore, please follow the new convention :)

Copy link
Author

Choose a reason for hiding this comment

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

gave the new convention a go @deiga. let me know if it's correct

},
"public": {
Type: schema.TypeBool,
Computed: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: This doesn't seem to get set anywhere and in the docs you write that it's optional. Did you mean to use Optional here? Should it have Default: false as well to remove the need for type-checking this later?

Copy link
Author

Choose a reason for hiding this comment

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

I'm unsure which is the best option here. From the docs

To publish a GitHub Pages site privately, your organization must use GitHub Enterprise Cloud. For more information about how you can try GitHub Enterprise Cloud for free, see Setting up a trial of GitHub Enterprise Cloud.
If your enterprise uses Enterprise Managed Users, GitHub Pages sites can only be published as private, and all GitHub Pages sites are only accessible to other enterprise members. For more information about Enterprise Managed Users, see GitHub Pages limits.
If your organization uses GitHub Enterprise Cloud without Enterprise Managed Users, you can choose to publish your project sites privately or publicly to anyone on the internet.

So there's no clear default since:

  1. anyone without github enterprise will be forced to have public pages
  2. If you have enterprise and Enterprise Managed Users, the pages can only be private
  3. only users that have enterprise and not Enterprise Managed Users can choose between public and private

I guess Computed: true is safer?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, that does look problematic. I think that having only Computed: true prevents users from setting the value, which would be unwelcome for GHEC non-EMU cases.

Maybe you could check if the SDK sends the field or it's left blank, otherwise the Create and Update need to ensure it's not being sent unless explicitly set.

You're right that Default isn't a good idea, but I guess it needs to be Computed & Optional


* `cname` - (Optional) The custom domain for the repository. This can only be set after the repository has been created.

* `public` - (Optional) Whether the GitHub Pages site is publicly visible. If set to `true`, the site is accessible to anyone on the internet. If set to `false`, the site will only be accessible to users who have at least `read` access to the repository that published the site.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a link to the section in the GH docs about the limitations for different Owner types? I think that would be valuable info for users

)

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

Choose a reason for hiding this comment

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

nitpick: we have a skipUnlessHasOrgs (or similar) function

@BartolottiLuca
Copy link
Author

@deiga sorry it took me so long, I've applied all the suggestions

Copy link
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.

Could you rebase your branch on top of this PR and moving your changes to the pages resource? :)

We're in the process of deprecating the pages config in github_repository

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: Add support for 'public' attribute on github pages configuration

4 participants