-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix(terraform): create pr only if workflow files content is different #19
fix(terraform): create pr only if workflow files content is different #19
Conversation
jneo8
commented
May 30, 2024
- Fix: [Terraform] New PR will be created even if there are no changes in workflow files. #17
- Add document for branch production rule if it's not exists.
- Update terraform workflow to use plan output instead re-plan when apply.
- Fix: #17 - Add document for branch production rule if it's not exists. - Update terraform workflow to use plan output instead re-plan when apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think it's working as expected, since in plan I can see that it will create branch for PR, push file and create PR. Or I do not understand it correctly?
Can you explain more? I am not sure what is your issue. There are some conditions to make sure the pr won't be created if the files are the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think that this plan should do nothing, or not? Also, why do we need to use output here? |
There is a local variable
The branch and pr will be created if there are any file difference been detected. Those plans show on |
Since the plan is stored and then applied, I do not think that the PR will not be created. Let's try it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it manually and it's not creating new PR. Good job @jneo8!
x1:➜ terraform-plans git:(fix/terraform-create-pr-even-no-changes-in-workflow-files) ✗ terraform apply "./tf.plan"
module.github_settings.github_repository.repo: Importing... [id=soleng-tf-test-repo]
module.github_settings.github_repository.repo: Import complete [id=soleng-tf-test-repo]
module.github_settings.github_branch_protection.branch_protection: Importing... [id=soleng-tf-test-repo:main]
module.github_settings.github_branch_protection.branch_protection: Import complete [id=soleng-tf-test-repo:main]
module.github_workflow_files.random_string.update_uid: Creating...
module.github_workflow_files.random_string.update_uid: Creation complete after 0s [id=jiboU3hG]
module.github_settings.github_repository_collaborators.repo_collaborators: Creating...
module.github_settings.github_branch_protection.branch_protection: Modifying... [id=BPR_kwDOL00SBM4DBTJ-]
module.github_settings.github_repository_collaborators.repo_collaborators: Still creating... [10s elapsed]
module.github_settings.github_branch_protection.branch_protection: Still modifying... [id=BPR_kwDOL00SBM4DBTJ-, 10s elapsed]
module.github_settings.github_branch_protection.branch_protection: Modifications complete after 11s [id=BPR_kwDOL00SBM4DBTJ-]
module.github_settings.github_repository_collaborators.repo_collaborators: Creation complete after 14s [id=soleng-tf-test-repo]
Apply complete! Resources: 2 imported, 2 added, 1 changed, 0 destroyed.
Outputs:
branch = "main"
changed_files = {}
pr_branch = "No PR created"
pr_created = false
pr_url = "No PR created"
repository = "soleng-tf-test-repo"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see other approvals, but there is still unresolved internal discussion around:
terraform plan
in CI not being consistent withterraform apply
because of how we use (or don't use) state.- whether to use matrix in github workflow
- whether to use state
I'm uneasy with leaving these unresolved since changes to this repo could have a large impact to our projects (ie. cause terraform to be applied to all our repos). So I'm going to leave my review in request changes until these discussions are resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is still in pilot/experimental stage, it seems it's fine to merge and iterate on later once the topics are resolved, so I won't block this any longer. :)