Skip to content

Commit b86f40d

Browse files
committed
Fix workflow: Terraform Apply only on PR merge
Change trigger from push to pull_request with merged condition. This ensures infrastructure is only deployed when PRs are merged, not on direct pushes to main.
1 parent 0f84177 commit b86f40d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

.github/workflows/terraform-apply.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: 'Terraform Apply'
22

33
on:
4-
push:
4+
pull_request:
5+
types: [closed]
56
branches:
67
- main
78

@@ -17,6 +18,7 @@ jobs:
1718
name: 'Terraform'
1819
runs-on: ubuntu-latest
1920
environment: production
21+
if: github.event.pull_request.merged == true
2022

2123
steps:
2224
- name: Checkout
@@ -81,7 +83,6 @@ jobs:
8183
echo "✅ No expensive resources detected. Safe to deploy!"
8284
8385
- name: Terraform Apply
84-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
8586
run: terraform apply -auto-approve tfplan
8687

8788
- name: Terraform Output

0 commit comments

Comments
 (0)