Refactor CI pipeline conditions to improve handling of skipped jobs a… #97
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
| name: Solar System - Main Pipeline | |
| on: | |
| push: # Auto-trigger on push | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| skip-tests: | |
| description: 'Skip CI tests' | |
| required: false | |
| default: false | |
| type: boolean | |
| skip-docker: | |
| description: 'Skip Docker build' | |
| required: false | |
| default: false | |
| type: boolean | |
| skip-terraform: | |
| description: 'Skip Terraform deployment' | |
| required: false | |
| default: false | |
| type: boolean | |
| skip-argocd: | |
| description: 'Skip ArgoCD deployment' | |
| required: false | |
| default: false | |
| type: boolean | |
| skip-monitoring: | |
| description: 'Skip Monitoring deployment' | |
| required: false | |
| default: false | |
| type: boolean | |
| skip-deployment: | |
| description: 'Skip Application deployment' | |
| required: false | |
| default: false | |
| type: boolean | |
| force-all: # Force all workflows | |
| description: 'Force run all workflows (ignore path detection)' | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| actions: read | |
| jobs: | |
| # Detect what changed | |
| detect-changes: | |
| name: Detect Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| app-changed: ${{ steps.changes.outputs.app }} | |
| infra-changed: ${{ steps.changes.outputs.infra }} | |
| is-manual: ${{ github.event_name == 'workflow_dispatch' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 2 | |
| - name: Detect file changes | |
| uses: dorny/paths-filter@v2 | |
| id: changes | |
| with: | |
| filters: | | |
| app: | |
| - 'app-controllers/**' | |
| - 'app-test.js' | |
| - 'app.js' | |
| - 'index.html' | |
| - 'Dockerfile' | |
| - 'package*.json' | |
| - 'images/**' | |
| - '.github/workflows/ci.yml' | |
| - '.github/workflows/docker.yml' | |
| infra: | |
| - 'Terraform/**' | |
| - '.github/workflows/terraform.yml' | |
| - '.github/workflows/argocd.yml' | |
| - 'argocd/application.yml' | |
| - '.github/workflows/deploy.yml' | |
| - 'argocd/monitoring.yml' | |
| - '.github/workflows/monitoring.yml' | |
| ci: | |
| name: Run CI Tests | |
| needs: [detect-changes] | |
| if: | | |
| !inputs.skip-tests && ( | |
| inputs.force-all || | |
| (github.event_name == 'workflow_dispatch') || | |
| needs.detect-changes.outputs.app-changed == 'true' | |
| ) | |
| uses: ./.github/workflows/ci.yml | |
| secrets: inherit | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| actions: read | |
| # Docker Build - runs after CI when app changes or manual dispatch | |
| docker: | |
| name: Build Docker Image | |
| needs: [ci, detect-changes] | |
| if: | | |
| !cancelled() && | |
| !inputs.skip-docker && | |
| (needs.ci.result == 'success' || (needs.ci.result == 'skipped' && inputs.skip-tests)) && ( | |
| inputs.force-all || | |
| (github.event_name == 'workflow_dispatch') || | |
| needs.detect-changes.outputs.app-changed == 'true' | |
| ) | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| actions: read | |
| uses: ./.github/workflows/docker.yml | |
| secrets: inherit | |
| # Terraform - runs after docker (for linear flow) when infra changes or manual dispatch | |
| terraform: | |
| name: Deploy Infrastructure | |
| needs: [docker, detect-changes] | |
| if: | | |
| !cancelled() && | |
| !inputs.skip-terraform && ( | |
| needs.docker.result == 'success' || | |
| needs.docker.result == 'skipped' || | |
| (needs.detect-changes.outputs.infra-changed == 'true' && needs.detect-changes.outputs.app-changed == 'false') | |
| ) && ( | |
| inputs.force-all || | |
| (github.event_name == 'workflow_dispatch') || | |
| needs.detect-changes.outputs.infra-changed == 'true' | |
| ) | |
| uses: ./.github/workflows/terraform.yml | |
| secrets: inherit | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| actions: read | |
| # ArgoCD - runs after terraform when infra changes or manual dispatch | |
| argocd: | |
| name: Deploy ArgoCD Applications | |
| needs: [terraform, detect-changes] | |
| if: | | |
| !cancelled() && | |
| !inputs.skip-argocd && | |
| (needs.terraform.result == 'success' || (needs.terraform.result == 'skipped' && inputs.skip-terraform)) && ( | |
| inputs.force-all || | |
| (github.event_name == 'workflow_dispatch') || | |
| needs.detect-changes.outputs.infra-changed == 'true' | |
| ) | |
| uses: ./.github/workflows/argocd.yml | |
| secrets: inherit | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| actions: read | |
| # Application Deployment - runs after ArgoCD when infra changes or manual dispatch | |
| deployment: | |
| name: Deploy Application | |
| needs: [argocd, detect-changes] | |
| if: | | |
| !cancelled() && | |
| !inputs.skip-deployment && | |
| (needs.argocd.result == 'success' || (needs.argocd.result == 'skipped' && inputs.skip-argocd)) && ( | |
| inputs.force-all || | |
| (github.event_name == 'workflow_dispatch') || | |
| needs.detect-changes.outputs.infra-changed == 'true' | |
| ) | |
| uses: ./.github/workflows/deploy.yml | |
| secrets: inherit | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| actions: read | |
| # Monitoring - runs after deployment when infra changes or manual dispatch | |
| monitoring: | |
| name: Deploy Monitoring Stack | |
| needs: [deployment, detect-changes] | |
| if: | | |
| !cancelled() && | |
| !inputs.skip-monitoring && | |
| (needs.deployment.result == 'success' || (needs.deployment.result == 'skipped' && inputs.skip-deployment)) && ( | |
| inputs.force-all || | |
| (github.event_name == 'workflow_dispatch') || | |
| needs.detect-changes.outputs.infra-changed == 'true' | |
| ) | |
| uses: ./.github/workflows/monitoring.yml | |
| secrets: inherit | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| actions: read | |
| # Show endpoints - runs at the end when any deployment happened | |
| show-endpoints: | |
| name: Show Service Endpoints | |
| needs: [detect-changes, argocd, deployment, monitoring] | |
| if: | | |
| !cancelled() && ( | |
| (github.event_name == 'workflow_dispatch') || | |
| (needs.detect-changes.outputs.infra-changed == 'true' && ( | |
| needs.argocd.result == 'success' || | |
| needs.deployment.result == 'success' || | |
| needs.monitoring.result == 'success' | |
| )) | |
| ) | |
| uses: ./.github/workflows/endpoints.yml | |
| secrets: inherit | |
| permissions: | |
| contents: read | |
| id-token: write |