Visitar URL original
feat: add fork PR contributor approval resources and data sources by benlangfeld · Pull Request #3726 · integrations/terraform-provider-github · GitHub
Skip to content

feat: add fork PR contributor approval resources and data sources - #3726

Draft
benlangfeld wants to merge 2 commits into
integrations:mainfrom
benlangfeld:fork-pr-contributor-approval
Draft

benlangfeld wants to merge 2 commits into
integrations:mainfrom
benlangfeld:fork-pr-contributor-approval

Conversation

@benlangfeld

Copy link
Copy Markdown

Resolves #3445

Supersedes #3446, which has been waiting since September on @donicrosby to confirm they're still working on it. Their commit is kept as-is, with Doni as author.


Before the change?

  • The fork PR contributor approval policy ("Approval for running fork pull request workflows from contributors") can't be managed with Terraform, so organizations that manage everything else about their repositories here have to set it by hand or through the API.

After the change?

  • Same resources and data sources as feat: add fork-PR contributor approval resources and data sources #3446, rebuilt on current main. Doni's commit only moves its imports from go-github v86 to v92.
  • A second commit brings github_actions_repository_fork_pr_contributor_approval up to the pattern newer repository-scoped resources follow:
    • It tracks the repository by ID through diffRepository. Renaming the repository updates the resource in place; pointing it at another repository replaces it. Before, changing repository left the old repository's policy behind.
    • A deleted repository drops the resource from state instead of failing the refresh.
  • The type assertions in the new files are checked, which the strict lint config for new code requires.

Testing

make lintcheck, the strict lint for new code (.golangci.new.yml, --new-from-merge-base main) and make test pass.

Acceptance tests have not been run on this version yet. The repository resource's tests cover the new rename and replace behaviour, and I'll run them against a personal account before marking this ready. The organization resource is unchanged apart from the lint fix; #3446's description records its acceptance test passing.

I edited docs/resources/actions_repository_fork_pr_contributor_approval.md by hand to match its template, because make generatedocs fails locally on a clean main with Terraform 1.17.

Pull request checklist

  • Schema migrations have been created if needed: not needed, these are new resources
  • 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

AI use

Written with Claude Code, which also helped draft this description. I've reviewed the change against the provider's existing patterns and stand behind it. It stays a draft until the acceptance tests have run.

🤖 Generated with Claude Code

donicrosby and others added 2 commits November 11, 2026 19:36
Wrap the GitHub REST `actions/permissions/fork-pr-contributor-approval`
endpoints (repo + org) in four new Terraform building blocks:

- resource `github_actions_repository_fork_pr_contributor_approval`
- resource `github_actions_organization_fork_pr_contributor_approval`
- data source `github_actions_repository_fork_pr_contributor_approval`
- data source `github_actions_organization_fork_pr_contributor_approval`

Each accepts `approval_policy` in the three GitHub-documented enum values
(`first_time_contributors_new_to_github`, `first_time_contributors`,
`all_external_contributors`).

The API has no "off" state for this policy. On Delete, the resource resets
the policy to GitHub's documented default (`first_time_contributors`) to
avoid leaving non-default residual state, matching the precedent set by
`github_actions_organization_permissions` Delete (which resets to `all`).

go-github already exposes the matching service methods on `*ActionsService`
(GetForkPRContributorApprovalPermissions / Update... and the Organization*
variants), so this is purely a provider-side wrapper.

New resources are implemented with context-aware CRUD functions
(`CreateContext` / `ReadContext` / `UpdateContext` / `DeleteContext`
returning `diag.Diagnostics`) per the migration tracked in integrations#2996, rather
than copying the legacy pattern from the nearby `access_level` and
`organization_permissions` resources that are themselves on that
migration's to-do list.

Acceptance test notes:
- Repo-level tests use `visibility = "public"` because configuring
  `fork-pr-contributor-approval` on private repos returns 422 when the
  org's `fork-pr-workflows-private-repos` setting has fork-PR workflows
  disabled. Public repos exercise the endpoint without that prerequisite.
- The repo-level test allows both `individual` and `organization` auth
  modes so it can be exercised against an org-scoped test token.

Doc generation was authored against `make generatedocs` templates and the
rendered output is included; `make validatedocs` was not run locally because
the dev environment lacks a `terraform` binary. CI will validate.
Follow the pattern newer repository-scoped resources use: store the
repository ID and diff on it, so renaming the repository updates the
resource in place while pointing it at another repository replaces it.
A deleted repository now drops the resource from state instead of
failing the refresh.

Also check type assertions, which the strict lint config requires of
new code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

@benlangfeld

Copy link
Copy Markdown
Author

Hey @acouvreur would you mind taking a look at this one?

This branch has not been deployed

No deployments
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.

[FEAT]: Add github_actions_*_fork_pr_contributor_approval resources and data sources

2 participants