Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: Allow creating deployment policies that match tags #1948

Open
1 task done
daniel-jimenezgarcia-ow opened this issue Oct 9, 2023 · 8 comments
Open
1 task done
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request

Comments

@daniel-jimenezgarcia-ow
Copy link

Describe the need

Deployment policies now allows creating policies that match either branches or tags: https://github.blog/changelog/2023-10-06-actions-secure-deployment-rollouts-to-protected-environments-based-on-select-tag-patterns/

However in Terraform we only have the github_repository_deployment_branch_policy available, which creates policies that match branches.

We need the ability to create policies that match tags (In the UX, you select a "ref type" when creating the policy).
This could either be via a new ref_type parameter in the existing resource or a new resource like github_repository_deployment_tag_policy

Note
I haven't seen this exposed in github's REST API. It might take some time for this new feature to be exposed in the API, and from there in the go-github client! I thought it would be helpful to have this item, even if in a "blocked" state, but you might disagree and prefer to close it, which I also understand.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@daniel-jimenezgarcia-ow daniel-jimenezgarcia-ow added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels Oct 9, 2023
@github-project-automation github-project-automation bot moved this to 🆕 Triage in 🧰 Octokit Active Oct 9, 2023
@george-zubrienko
Copy link

This is needed in order to update repos after the security fix which broke the old way of doing tag-based deployment protection.

https://github.blog/changelog/2023-10-06-actions-secure-deployment-rollouts-to-protected-environments-based-on-select-tag-patterns/

@nickfloyd nickfloyd moved this from 🆕 Triage to 👀 In review in 🧰 Octokit Active Oct 9, 2023
@nickfloyd nickfloyd moved this from 👀 In review to 🔥 Backlog in 🧰 Octokit Active Oct 10, 2023
@nickfloyd nickfloyd added Status: Up for grabs Issues that are ready to be worked on by anyone hacktoberfest Issues for participation in Hacktoberfest and removed Status: Triage This is being looked at and prioritized labels Oct 10, 2023
@george-zubrienko
Copy link

Has the work started on this? Or should we do the scriptops again? :)

@daniel-jimenezgarcia-ow
Copy link
Author

Worth noting this is now added to the REST API, as well as v56 version of go-github client (which added a new Type parameter for the DeploymentBranchPolicy and DeploymentBranchPolicyRequest types)

@kfcampbell
Copy link
Member

@george-zubrienko it has not; PRs are very welcome!

@tjespers
Copy link

Hi 👋

We're currently migrating to became a Terraform managed GitHub organization. This feature is something that would benefit us greatly so if i've dug a bit into the implementation of this resource.

I'm entirely new to writing terraform providers so please correct me when i got things at the wrong end here, but the way i see it there are roughly 2 ways to implement this:

  • rename the branch_pattern property to something like pattern and adding a secondary option to control the type to match (branches / tags).
    • pros: provides a clean and simple API to work with, follows the github API spec more closely
    • cons: Introduces a breaking change requiring this to be a major version bump
  • making the property branch_pattern optional and putting a tag_pattern to sit as it's counterpart.
    • pros: Does not introduce a breaking change
    • cons: Introduces 2 attributes that are mutually exclusive possibly requiring a more complex implementation, also i'm not sure if this is something that is common / good practice to do when writing terraform providers?

I was wondering if there is a best-practice / general consensus on what would be the preferred approach to a problem like this when it comes to TF providers?

@mcevoypeter
Copy link
Contributor

FYI: I implemented the first approach in the comment above for the github_repository_environment_deployment_policy resource in #2050 and am awaiting feedback. The implementation should be simple to apply to the github_repository_deployment_branch_policy as well.

@anfigueroa
Copy link

This is becoming an issue in our organization, we need to be able to manage this through IaC. How come this has been implemented since Dec 2023 but nothing has advanced since then? Is there a way to help this move forward?

@mmadhur-cops
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants