File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ name : " Deploy node-exporter agent on k8s cluster with Terraform"
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ # Step 1: Checkout repository
14+ - name : Checkout repository
15+ uses : actions/checkout@v4
16+
17+ # Step 2: Setup Terraform
18+ - name : Setup Terraform
19+ uses : hashicorp/setup-terraform@v3
20+
21+ # Step 3: Configure kubeconfig
22+ - name : Configure kubeconfig
23+ run : |
24+ mkdir -p $HOME/.kube
25+ echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
26+
27+ # Step 4: Terraform Init
28+ - name : Terraform Init
29+ run : terraform init
30+
31+ # Step 5: Terraform Validate
32+ - name : Terraform Validate
33+ run : terraform validate
34+
35+ # Step 6: Terraform Plan
36+ - name : Terraform Plan
37+ run : terraform plan -out=tfplan
38+
39+ # Step 7: Terraform Apply (only on main branch)
40+ - name : Terraform Apply
41+ if : github.ref == 'refs/heads/main'
42+ run : terraform apply -auto-approve tfplan
43+ env :
44+ KUBECONFIG : $HOME/.kube/config
You can’t perform that action at this time.
0 commit comments