1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches : [main, develop]
6+ pull_request :
7+ branches : [main]
8+ schedule :
9+ - cron : ' 0 0 * * 0' # Weekly security scan
10+
11+ jobs :
12+ lint :
13+ name : Lint Code
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v4
17+
18+ - name : Setup Node.js
19+ uses : actions/setup-node@v4
20+ with :
21+ node-version : ' 18'
22+ cache : ' npm'
23+
24+ - name : Install dependencies
25+ run : npm ci
26+
27+ - name : Run ESLint
28+ run : npm run lint
29+
30+ - name : Check Prettier formatting
31+ run : npx prettier --check "**/*.{js,json,md}"
32+
33+ test-node :
34+ name : Test Node.js
35+ runs-on : ubuntu-latest
36+ needs : lint
37+ strategy :
38+ matrix :
39+ node-version : [16.x, 18.x, 20.x]
40+ steps :
41+ - uses : actions/checkout@v4
42+
43+ - name : Setup Node.js ${{ matrix.node-version }}
44+ uses : actions/setup-node@v4
45+ with :
46+ node-version : ${{ matrix.node-version }}
47+ cache : ' npm'
48+
49+ - name : Install dependencies
50+ run : npm ci
51+
52+ - name : Run tests with coverage
53+ run : npm test -- --coverage
54+
55+ - name : Upload coverage
56+ if : matrix.node-version == '18.x'
57+ uses : codecov/codecov-action@v3
58+ with :
59+ file : ./coverage/lcov.info
60+ flags : unittests
61+ name : codecov-umbrella
62+
63+ test-python :
64+ name : Test Python
65+ runs-on : ubuntu-latest
66+ needs : lint
67+ strategy :
68+ matrix :
69+ python-version : ['3.9', '3.10', '3.11']
70+ steps :
71+ - uses : actions/checkout@v4
72+
73+ - name : Setup Python ${{ matrix.python-version }}
74+ uses : actions/setup-python@v4
75+ with :
76+ python-version : ${{ matrix.python-version }}
77+
78+ - name : Cache pip
79+ uses : actions/cache@v3
80+ with :
81+ path : ~/.cache/pip
82+ key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
83+
84+ - name : Install dependencies
85+ run : |
86+ python -m pip install --upgrade pip
87+ pip install -r requirements.txt
88+ pip install pytest pytest-cov flake8 black
89+
90+ - name : Lint with flake8
91+ run : flake8 python-automation --count --max-complexity=10 --max-line-length=100
92+
93+ - name : Check formatting with black
94+ run : black --check python-automation
95+
96+ - name : Run tests
97+ run : pytest --cov=python-automation --cov-report=xml
98+
99+ - name : Upload coverage
100+ if : matrix.python-version == '3.11'
101+ uses : codecov/codecov-action@v3
102+ with :
103+ file : ./coverage.xml
104+ flags : python
105+ name : codecov-python
106+
107+ test-powershell :
108+ name : Test PowerShell
109+ runs-on : windows-latest
110+ needs : lint
111+ steps :
112+ - uses : actions/checkout@v4
113+
114+ - name : Run Pester tests
115+ shell : pwsh
116+ run : |
117+ Install-Module -Name Pester -Force -SkipPublisherCheck
118+ Import-Module Pester
119+ $config = New-PesterConfiguration
120+ $config.Run.Path = './tests'
121+ $config.Output.Verbosity = 'Detailed'
122+ $config.CodeCoverage.Enabled = $true
123+ Invoke-Pester -Configuration $config
124+
125+ security-scan :
126+ name : Security Scan
127+ runs-on : ubuntu-latest
128+ steps :
129+ - uses : actions/checkout@v4
130+
131+ - name : Run Trivy vulnerability scanner
132+ uses : aquasecurity/trivy-action@master
133+ with :
134+ scan-type : ' fs'
135+ scan-ref : ' .'
136+ format : ' sarif'
137+ output : ' trivy-results.sarif'
138+
139+ - name : Upload Trivy results to GitHub Security
140+ uses : github/codeql-action/upload-sarif@v2
141+ with :
142+ sarif_file : ' trivy-results.sarif'
143+
144+ - name : Run npm audit
145+ run : npm audit --production
146+ continue-on-error : true
147+
148+ - name : Run pip safety check
149+ run : |
150+ pip install safety
151+ safety check --file requirements.txt
152+ continue-on-error : true
153+
154+ build-docker :
155+ name : Build Docker Images
156+ runs-on : ubuntu-latest
157+ needs : [test-node, test-python, test-powershell]
158+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
159+ steps :
160+ - uses : actions/checkout@v4
161+
162+ - name : Set up Docker Buildx
163+ uses : docker/setup-buildx-action@v3
164+
165+ - name : Log in to Docker Hub
166+ uses : docker/login-action@v3
167+ with :
168+ username : ${{ secrets.DOCKER_USERNAME }}
169+ password : ${{ secrets.DOCKER_PASSWORD }}
170+
171+ - name : Build and push API image
172+ uses : docker/build-push-action@v5
173+ with :
174+ context : .
175+ file : ./infrastructure/Dockerfile.api
176+ push : true
177+ tags : |
178+ ${{ secrets.DOCKER_USERNAME }}/adobe-automation-api:latest
179+ ${{ secrets.DOCKER_USERNAME }}/adobe-automation-api:${{ github.sha }}
180+ cache-from : type=gha
181+ cache-to : type=gha,mode=max
182+
183+ - name : Build and push Python image
184+ uses : docker/build-push-action@v5
185+ with :
186+ context : .
187+ file : ./infrastructure/Dockerfile.python
188+ push : true
189+ tags : |
190+ ${{ secrets.DOCKER_USERNAME }}/adobe-automation-python:latest
191+ ${{ secrets.DOCKER_USERNAME }}/adobe-automation-python:${{ github.sha }}
192+ cache-from : type=gha
193+ cache-to : type=gha,mode=max
194+
195+ - name : Build and push PowerShell image
196+ uses : docker/build-push-action@v5
197+ with :
198+ context : .
199+ file : ./infrastructure/Dockerfile.powershell
200+ push : true
201+ tags : |
202+ ${{ secrets.DOCKER_USERNAME }}/adobe-automation-powershell:latest
203+ ${{ secrets.DOCKER_USERNAME }}/adobe-automation-powershell:${{ github.sha }}
204+ cache-from : type=gha
205+ cache-to : type=gha,mode=max
206+
207+ deploy :
208+ name : Deploy to Production
209+ runs-on : ubuntu-latest
210+ needs : [build-docker, security-scan]
211+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
212+ environment : production
213+ steps :
214+ - uses : actions/checkout@v4
215+
216+ - name : Deploy to Kubernetes
217+ run : |
218+ echo "Deployment step - configure kubectl and apply manifests"
219+ # kubectl apply -f infrastructure/kubernetes/
220+
221+ - name : Verify deployment
222+ run : |
223+ echo "Verify deployment health"
224+ # kubectl rollout status deployment/adobe-automation-api
225+
226+ release :
227+ name : Create Release
228+ runs-on : ubuntu-latest
229+ needs : deploy
230+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
231+ steps :
232+ - uses : actions/checkout@v4
233+
234+ - name : Create Release
235+ if : startsWith(github.ref, 'refs/tags/')
236+ uses : softprops/action-gh-release@v1
237+ with :
238+ files : |
239+ dist/*
240+ reports/*
241+ generate_release_notes : true
0 commit comments