Skip to content

[FEAT]: support pull_request_creation_policy on github_repository #3348

@RoFz

Description

@RoFz

Describe the need

The provider currently has no support for the repository-level pull_request_creation_policy setting, which controls who can create pull requests in a repository.

I maintain a separate github-infra repo that manages my GitHub repositories through this provider. Because this setting is missing, that repo currently has to patch it out-of-band with a curl call against the GitHub API during Terraform apply:

  • desired Terraform surface: github_repository.pull_request_creation_policy
  • values currently in use: collaborators_only and all
  • current workaround: a local terraform_data + local-exec curl -X PATCH /repos/{owner}/{repo} call in the infra module

This means the repository resource cannot fully express the repo settings being managed, and the workaround has to exist outside normal provider state handling.

SDK Version

terraform-provider-github (current main branch)

API Version

GitHub REST API 2022-11-28 in the current workaround; GitHub GraphQL also exposes pullRequestCreationPolicy and update support.

Relevant log output

Current workaround in github-infra:

curl -s -f \
  -X PATCH \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  "https://api.github.com/repos/${var.owner}/${var.name}" \
  -d '{"pull_request_creation_policy":"${var.pull_request_creation_policy}"}'

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions