integrations / integrations/terraform-provider-github

[FEAT]: support pull_request_creation_policy on github_repository

Open
#3,348 3 comments 0 reactions 0 assignees View on GitHub
r/repository
Dominant language
Go
Stars
1.2k
Forks
1k
Avg merge
1d 14h
Merged PRs (30d)
8

Description

## 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`:

```shell
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

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.