ci(tf-integration): trigger on PR approve, not every push - #1272
Open
LeonardCareer wants to merge 1 commit into
Open
ci(tf-integration): trigger on PR approve, not every push#1272LeonardCareer wants to merge 1 commit into
LeonardCareer wants to merge 1 commit into
Conversation
Adds a gate job that only lets terraform-test/plan proceed when the review is approved AND the PR touches tf files. Cuts approval-email noise.
LeonardCareer
requested review from
alyssa1303,
liyu-ma,
sumanthreddy29,
vittoriasalim,
wonderyl and
xinWeiWei24
as code owners
July 29, 2026 01:43
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the Terraform Integration GitHub Actions workflow to reduce privileged-environment approval spam by triggering the workflow on PR review submission and adding a gating job that only enables the terraform jobs when terraform-related files are touched.
Changes:
- Switch workflow trigger from
pull_request_target(path-filtered) topull_request_review(types: [submitted]). - Add a
gatejob that usesgh apito detect whether the PR touches terraform-related paths and outputsrun=true/false. - Make
terraform-testandsetup-matrixdepend ongateand run only whengateoutputsrun == 'true'.
Comment on lines
+18
to
+23
| gate: | ||
| if: github.event.review.state == 'approved' | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| run: ${{ steps.check.outputs.run }} | ||
| steps: |
Comment on lines
6
to
+8
| on: | ||
| pull_request_target: | ||
| paths: | ||
| - '**.tf' | ||
| - '**.json' | ||
| - '**.tfvars' | ||
| - 'modules/terraform/**' | ||
| pull_request_review: | ||
| types: [submitted] |
wonderyl
reviewed
Jul 29, 2026
|
|
||
| jobs: | ||
| gate: | ||
| if: github.event.review.state == 'approved' |
Collaborator
There was a problem hiding this comment.
@liyu-ma, here is the dilemma. Suppose I'm a reviewer, I can't approve before I feel confident the change is correct, then I need to check the tf change is working. If I already checked it, the test is not useful anymore.
Alternatively. If this remains a pr check, a reviewer can trigger it before he starts reviewing and check back the result later.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Move the
Terraform Integrationworkflow from being triggered on every push (pull_request_target) to being triggered only when a reviewer submits an approval (pull_request_review).Why
Per scrum discussion — every fork PR push currently spams every environment reviewer with a
deployment review requestedemail (one per matrix job, tens of emails per push). Moving the trigger to "review submitted" means reviewers only get the approval request once, after they've read the code.Tradeoff Lei raised: tf plan results are no longer visible pre-review. Consensus was to try this and see how it goes.
How
pull_request_target→pull_request_review: types: [submitted]gatejob with two conditions:if: github.event.review.state == 'approved'— skip on comment/request-changesgh apito fetch PR file list, setsrun=trueonly if any file matches.tf$,.tfvars$,modules/terraform/**, orscenarios/*/terraform-(inputs|test-inputs)/**terraform-testandsetup-matrixnowneeds: gate+if: needs.gate.outputs.run == 'true'terraform-planchain unchanged (inherits fromsetup-matrix)Test plan
Related: MSRC #127928.