ci: add production CI, release, and security scan workflows #5
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: CI | |
| on: | |
| push: | |
| branches: [main, develop, 'feature/**', 'bugfix/**'] | |
| pull_request: | |
| branches: [main, develop] | |
| permissions: | |
| contents: read | |
| security-events: write | |
| jobs: | |
| validate: | |
| name: Validate Configuration | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Validate Docker Compose files | |
| run: | | |
| for f in docker/docker-compose.*.yml; do | |
| echo "Validating: $f" | |
| docker compose -f "$f" config --no-interpolate -q | |
| done | |
| - name: ShellCheck — lab test scripts | |
| run: | | |
| sudo apt-get install -y shellcheck -qq | |
| shellcheck tests/labs/*.sh | |
| - name: Validate module manifest | |
| run: | | |
| python3 -c " | |
| import sys, re | |
| with open('it-stack-postgresql.yml') as f: | |
| content = f.read() | |
| required = ['module:', 'version:', 'phase:', 'category:', 'ports:'] | |
| missing = [k for k in required if k not in content] | |
| if missing: | |
| print('Missing fields:', missing); sys.exit(1) | |
| print('Manifest valid') | |
| " | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| needs: validate | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Trivy — scan Dockerfile | |
| uses: aquasecurity/trivy-action@0.28.0 | |
| with: | |
| scan-type: config | |
| scan-ref: . | |
| exit-code: '0' | |
| severity: CRITICAL,HIGH | |
| - name: Trivy — SARIF output | |
| uses: aquasecurity/trivy-action@0.28.0 | |
| with: | |
| scan-type: config | |
| scan-ref: . | |
| format: sarif | |
| output: trivy-results.sarif | |
| - name: Upload SARIF to GitHub Security | |
| uses: github/codeql-action/upload-sarif@v3 | |
| if: always() | |
| with: | |
| sarif_file: trivy-results.sarif | |
| lab-01-smoke: | |
| name: Lab 01 — Smoke Test | |
| runs-on: ubuntu-latest | |
| needs: validate | |
| continue-on-error: true # scaffold stubs; full lab runs on real VMs | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Generate CI env file | |
| run: | | |
| # Copy example env and inject CI-safe defaults for any unset port vars | |
| if [ -f .env.example ]; then cp .env.example .env; fi | |
| # Set port placeholder vars used in scaffold compose files | |
| echo "firstPort=389" >> .env | |
| echo "secondPort=9090" >> .env | |
| - name: Validate standalone compose can start | |
| run: | | |
| docker compose -f docker/docker-compose.standalone.yml config --no-interpolate -q | |
| echo "Standalone compose structure is valid" | |
| - name: Start standalone stack | |
| run: docker compose -f docker/docker-compose.standalone.yml up -d | |
| - name: Wait for health | |
| run: | | |
| echo "Waiting for services..." | |
| sleep 30 | |
| docker compose -f docker/docker-compose.standalone.yml ps | |
| - name: Run Lab 01 test script | |
| run: bash tests/labs/test-lab-01.sh | |
| - name: Collect logs on failure | |
| if: failure() | |
| run: docker compose -f docker/docker-compose.standalone.yml logs | |
| - name: Cleanup | |
| if: always() | |
| run: docker compose -f docker/docker-compose.standalone.yml down -v |