terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

Add support for tag-based environment deployment branch policy

Open mcevoypeter opened this issue 1 year ago • 10 comments
trafficstars

Resolves #1974


Before the change?

  • The github_repository_environment_deployment_policy only supported branch-based policies even though the GitHub API has support for both branch-based and tag-based policies.

After the change?

  • A tag_pattern attribute has been added to the github_repository_environment_deployment_policy resource.

Pull request checklist

  • [x] Tests for the changes have been added (for bug fixes / features)
  • [x] Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • [ ] Yes
  • [x] No

mcevoypeter avatar Dec 06 '23 19:12 mcevoypeter

I switched from a pattern + type approach to a branch_pattern + tag_pattern approach. The former was a breaking change, whereas the latter is not and is also simpler for users of the provider to use correctly.

mcevoypeter avatar Dec 14 '23 00:12 mcevoypeter

@kfcampbell, is there anything I can do to help move this along?

mcevoypeter avatar Dec 14 '23 00:12 mcevoypeter

Does repository need to be updated as well? github_repository_environment Currently it has deployment_branch_policy with custom_branch_policies.

Does it also need custom_tag_policies boolean?

brandocomando avatar Dec 14 '23 17:12 brandocomando

Does it [the github_repository_environment resource ]also need custom_tag_policies boolean?

I don't think so. The GitHub docs only lists two fields within the deployment_branch_policy object: protected_branches and custom_branch_policies.

mcevoypeter avatar Dec 14 '23 18:12 mcevoypeter

@mcevoypeter Sorry about the delay; it's been slow with holidays. Thank you for the contribution!

When running the newly-added tests, I get the following error that fails them:

    testing.go:705: Step 0 error: After applying this step, the plan was not empty:
        
        DIFF:
        
        UPDATE: github_repository_environment_deployment_policy.test
          branch_pattern: "v*" => ""
          environment:    "environment/test" => "environment/test"
          id:             "tf-acc-test-7vk43:environment%2Ftest:13663474" => "tf-acc-test-7vk43:environment%2Ftest:13663474"
          repository:     "tf-acc-test-7vk43" => "tf-acc-test-7vk43"
          tag_pattern:    "v*" => "v*"
        
        
        
        STATE:
        
        (left out for now)

Can you reproduce this? Do they succeed for you?

kfcampbell avatar Jan 05 '24 18:01 kfcampbell

Hi there! We're currently a bit blocked by this missing. Anything we could help with moving this forward?

boredland avatar Jan 31 '24 13:01 boredland

@boredland you're certainly welcome to take this code as it is, resolve the issues/conflicts, and submit as another PR! I'd be happy to review it should you decide to do so.

kfcampbell avatar Feb 05 '24 21:02 kfcampbell

@boredland, go for it. I've been swamped since the beginning of January and can't get to this for the forseeable future. Let me know if there's anything I can do to help with hand-off.

mcevoypeter avatar Feb 06 '24 19:02 mcevoypeter

Didn't find any time yet :(

boredland avatar Feb 19 '24 23:02 boredland

@kfcampbell I took a stab at reworking this in #2165.

sumnerwarren avatar Feb 20 '24 17:02 sumnerwarren

Thanks for the efforts here; closing in favor of https://github.com/integrations/terraform-provider-github/pull/2165.

nickfloyd avatar Aug 06 '24 18:08 nickfloyd