11name : Solar System - Main Pipeline 
22on :
3+   push :                     #  ← ADDED: Auto-trigger on push
4+     branches : [main] 
35  workflow_dispatch :
46    inputs :
57      skip-tests :
2224        required : false 
2325        default : false 
2426        type : boolean 
27+       force-all :              #  ← ADDED: Force all workflows
28+         description : ' Force run all workflows (ignore path detection)' 
29+         required : false 
30+         default : false 
31+         type : boolean 
2532
2633permissions :
2734  contents : write 
@@ -30,23 +37,61 @@ permissions:
3037  actions : read 
3138
3239jobs :
40+   #  ← NEW: Detect what changed
41+   detect-changes :
42+     name : Detect Changes 
43+     runs-on : ubuntu-latest 
44+     outputs :
45+       app-changed : ${{ steps.changes.outputs.app }} 
46+       terraform-changed : ${{ steps.changes.outputs.terraform }} 
47+       k8s-changed : ${{ steps.changes.outputs.k8s }} 
48+       any-changed : ${{ steps.changes.outputs.app == 'true' || steps.changes.outputs.terraform == 'true' || steps.changes.outputs.k8s == 'true' }} 
49+     steps :
50+       - name : Checkout 
51+         uses : actions/checkout@v5 
52+         with :
53+           fetch-depth : 2 
54+           
55+       - name : Detect file changes 
56+         uses : dorny/paths-filter@v2 
57+         id : changes 
58+         with :
59+           filters : | 
60+             app: 
61+               - 'app-controllers/**' 
62+               - 'app-test.js' 
63+               - 'app.js'  
64+               - 'index.html' 
65+               - 'Dockerfile' 
66+               - 'package*.json' 
67+               - 'images/**' 
68+               - '.github/workflows/ci.yml' 
69+               - '.github/workflows/docker.yml' 
70+             terraform: 
71+               - 'Terraform/**' 
72+               - '.github/workflows/terraform.yml' 
73+             k8s: 
74+               - 'argocd/**' 
75+               - '.github/workflows/deploy.yml' 
76+ 
3377   ci :
3478    name : Run CI Tests 
35-     if : ${{ !inputs.skip-tests }} 
79+     needs : [detect-changes] 
80+     if : ${{ !inputs.skip-tests && (inputs.force-all || needs.detect-changes.outputs.app-changed == 'true' || github.event_name == 'workflow_dispatch') }} 
3681    uses : ./.github/workflows/ci.yml 
3782    secrets : inherit 
38-     permissions :   
83+     permissions :
3984      contents : write 
4085      packages : write 
4186      id-token : write 
4287      actions : read 
4388
4489  docker :
4590    name : Build Docker Image 
46-     if : ${{ !inputs.skip-docker && (success() || inputs.skip-tests) }} 
47-     needs : [ci] 
91+     if : ${{ !inputs.skip-docker && (success() || inputs.skip-tests) && (inputs.force-all || needs.detect-changes.outputs.app-changed == 'true' || github.event_name == 'workflow_dispatch')  }} 
92+     needs : [ci, detect-changes ] 
4893    permissions :
49-       contents : write      
94+       contents : write 
5095      packages : write 
5196      id-token : write 
5297      actions : read 
57102
58103  terraform :
59104    name : Deploy Infrastructure 
60-     if : ${{ !inputs.skip-terraform && (success() || (inputs.skip-tests && inputs.skip-docker)) }} 
61-     needs : [docker] 
105+     if : ${{ !inputs.skip-terraform && (success() || (inputs.skip-tests && inputs.skip-docker)) && (inputs.force-all || needs.detect-changes.outputs.terraform-changed == 'true' || github.event_name == 'workflow_dispatch')  }} 
106+     needs : [docker, detect-changes ] 
62107    uses : ./.github/workflows/terraform.yml 
63108    secrets : inherit 
64109    permissions :
71116
72117  deploy :
73118    name : Deploy Application 
74-     if : ${{ !inputs.skip-deployment && (success() || (inputs.skip-tests && inputs.skip-docker && inputs.skip-terraform)) }} 
75-     needs : [terraform, docker] 
119+     if : ${{ !inputs.skip-deployment && (success() || (inputs.skip-tests && inputs.skip-docker && inputs.skip-terraform)) && (inputs.force-all || needs.detect-changes.outputs.k8s-changed == 'true' || needs.detect-changes.outputs.app-changed == 'true' || github.event_name == 'workflow_dispatch')  }} 
120+     needs : [terraform, docker, detect-changes ] 
76121    uses : ./.github/workflows/deploy.yml 
77122    secrets : inherit 
78123    permissions :
0 commit comments