Skip to content

feat: Add pull_request_creation_policy to github_repository#3349

Open
RoFz wants to merge 1 commit intointegrations:mainfrom
RoFz:feat/pull-request-creation-policy
Open

feat: Add pull_request_creation_policy to github_repository#3349
RoFz wants to merge 1 commit intointegrations:mainfrom
RoFz:feat/pull-request-creation-policy

Conversation

@RoFz
Copy link
Copy Markdown

@RoFz RoFz commented Apr 19, 2026

Resolves #3348


Before the change?

  • github_repository could not manage pull_request_creation_policy.
  • Users who needed to enforce it had to rely on out-of-band API calls or local workarounds.

After the change?

  • Add pull_request_creation_policy to github_repository as an optional, computed argument.
  • Support the all and collaborators_only values.
  • Read and update the setting through GitHub GraphQL so the provider can manage it even though the current REST client model does not expose the field.
  • Resolve the GraphQL read using the effective repository owner and skip hard failure when the remote GraphQL schema does not expose pullRequestCreationPolicy.
  • Add helper coverage, repository acceptance coverage, and resource documentation for the new argument.

Evidence

  • go test ./github -run 'TestPullRequestCreationPolicyMapping|TestRepositoryPullRequestCreationPolicyGraphQL|TestIsUnsupportedPullRequestCreationPolicyError' -count=1
  • make test
  • GH_TEST_AUTH_MODE=individual GITHUB_OWNER=RoFz GITHUB_USERNAME=RoFz make testacc T='TestAccGithubRepository/check_pull_request_creation_policy'
  • make lintcheck
  • Manual test with a local provider override on disposable repo tf-pr-creation-policy-manual-20260419-120606: terraform apply succeeded, GitHub API readback returned collaborators_only, and a follow-up terraform plan -detailed-exitcode returned no changes.

Pull request checklist

  • Schema migrations have been created if needed
  • 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?

  • 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! 🚀

@github-actions github-actions bot added the Type: Feature New feature or request label Apr 19, 2026
@RoFz RoFz force-pushed the feat/pull-request-creation-policy branch from 6f14748 to 4d4fe11 Compare April 19, 2026 11:38
@RoFz RoFz changed the title Add pull_request_creation_policy to github_repository feat: Add pull_request_creation_policy to github_repository Apr 19, 2026
@RoFz RoFz marked this pull request as ready for review April 19, 2026 11:41
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.

The github_repository resource relies solely on the REST API currently. If you need to use GQL API, then please do that in a separate resource.

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

Labels

Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: support pull_request_creation_policy on github_repository

2 participants