Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add build_type to github_repository (pages) #1663

Merged

Conversation

0x46616c6b
Copy link
Contributor

@0x46616c6b 0x46616c6b commented Apr 24, 2023

Resolves #1267


Behavior

Before the change?

  • It is not possible to configure a GitHub Pages with GitHub Actions

After the change?

  • The build_type option is added to pages property

Additional info

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)
  • Added the appropriate label for the given change

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes (Please add the Type: Breaking change label)
  • No

Open Questions

  • How can I ensure if the build_type = "legacy" that source is not optional anymore?
  • This PR is related with feat: Split out Pages resource #1617, can it be introduced before the resource is split out?

@0x46616c6b 0x46616c6b force-pushed the add-build-type-to-repository-pages branch 2 times, most recently from da8683f to e9f9867 Compare April 24, 2023 13:04
@0x46616c6b 0x46616c6b force-pushed the add-build-type-to-repository-pages branch from e9f9867 to 0c0f7ef Compare April 24, 2023 13:12
@0x46616c6b 0x46616c6b marked this pull request as ready for review April 24, 2023 13:16
@lukas-tide
Copy link

Looking forward to having this live

@lukas-tide
Copy link

@0x46616c6b to validate the field you could do the checks here

Validation functions are only supported for basic types, so the only option I have found is to do the checks on creation and update and in this case creation reuses update, so only update would work fine I guess. Maybe @kfcampbell could clarify if that is the case and if this is needed for the PR to get merged

* `source` - (Required) The source branch and directory for the rendered Pages site. See [GitHub Pages Source](#github-pages-source) below for details.
* `source` - (Optional) The source branch and directory for the rendered Pages site. See [GitHub Pages Source](#github-pages-source) below for details.

* `build_type` - (Optional) The type of GitHub Pages site to build. Can be `legacy` or `workflow`. If you use `legacy` as build type you need to set the option `source`.
Copy link
Member

Choose a reason for hiding this comment

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

What happens if both source and build_type are present, which one takes precedence? What happens if legacy is set for build_type but source isn't set?

Copy link
Contributor Author

@0x46616c6b 0x46616c6b May 17, 2023

Choose a reason for hiding this comment

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

To be honest I am not aware what the GitHub API will return when the options are not set correctly. I can only outline the possible usage. Would like to prevent this with the Terraform validation but not sure if this is possible.

Allowed Options

resource "github_repository" "example" {
  name = "example"

  pages {
    source {
      branch = "main"
      path = "/"
    }
    build_type = "legacy"
  }
}
resource "github_repository" "example" {
  name = "example"

  pages {
    source {
      branch = "main"
      path = "/"
    }
  }
}
resource "github_repository" "example" {
  name = "example"

  pages {
    build_type = "workflow"
  }
}

Problematic / wrong Configuration

resource "github_repository" "example" {
  name = "example"

  pages {
    source {
      branch = "main"
      path = "/"
    }
    build_type = "workflow"
  }
}

@kfcampbell
Copy link
Member

I'm okay with the validation approach; not running checks on creation/update should result in an error at the API level that will be passed back to the user in any case.

@0x46616c6b does this result in a breaking change for users? I'm not sure if providing "legacy" by default on all build_types results in any API-level changes or not.

@0x46616c6b
Copy link
Contributor Author

I understand that upgrading the provider and applying the changes will cause a difference (in state only), but it won't affect the repository configuration. If this change is considered a breaking change (due to the new key changing the state), we should reflect that too.

Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

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

I'm okay with state changing as a non-breaking change as long as the API/GitHub state remains consistent. Thanks!

@kfcampbell kfcampbell merged commit 1995238 into integrations:main May 19, 2023
soult added a commit to soult/terraform-provider-github that referenced this pull request Jun 3, 2023
PR integrations#1663 added the "build_type" attribute to the github_repository resource.
Since the corresponding data source uses the same code to parse the pages
endpoint data, any use of the github_repository datasource would lead to an
error, since the attribute did not exist there:

> Error: error setting pages: Invalid address to set: []string{"pages", "0", "build_type"}

This commit adds the missing attribute. The existing acceptance tests already
cover it, failed for me when running without this commit, and passed after.
@0x46616c6b 0x46616c6b deleted the add-build-type-to-repository-pages branch June 6, 2023 13:50
@benlangfeld
Copy link

This appears to have broken some use cases: #1724

kfcampbell added a commit that referenced this pull request Jun 14, 2023
PR #1663 added the "build_type" attribute to the github_repository resource.
Since the corresponding data source uses the same code to parse the pages
endpoint data, any use of the github_repository datasource would lead to an
error, since the attribute did not exist there:

> Error: error setting pages: Invalid address to set: []string{"pages", "0", "build_type"}

This commit adds the missing attribute. The existing acceptance tests already
cover it, failed for me when running without this commit, and passed after.

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
avidspartan1 pushed a commit to avidspartan1/terraform-provider-github that referenced this pull request Feb 5, 2024
Co-authored-by: Keegan Campbell <me@kfcampbell.com>
avidspartan1 pushed a commit to avidspartan1/terraform-provider-github that referenced this pull request Feb 5, 2024
…1710)

PR integrations#1663 added the "build_type" attribute to the github_repository resource.
Since the corresponding data source uses the same code to parse the pages
endpoint data, any use of the github_repository datasource would lead to an
error, since the attribute did not exist there:

> Error: error setting pages: Invalid address to set: []string{"pages", "0", "build_type"}

This commit adds the missing attribute. The existing acceptance tests already
cover it, failed for me when running without this commit, and passed after.

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
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.

github_repository pages source should allow for github actions source
4 participants