|
1 | | -# .github/workflows/ci.yml |
2 | | -name: CI |
| 1 | +name: CI/CD Pipeline |
3 | 2 |
|
4 | | -on: [push, pull_request] |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
5 | 10 |
|
6 | 11 | jobs: |
7 | 12 | build: |
8 | 13 | runs-on: ubuntu-latest |
9 | 14 |
|
10 | 15 | steps: |
11 | | - - uses: actions/checkout@v2 # Step to check out the code |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v2 |
| 18 | + |
12 | 19 | - name: Set up Python |
13 | | - uses: actions/setup-python@v2 # Step to set up Python on Window |
| 20 | + uses: actions/setup-python@v2 |
14 | 21 | with: |
15 | 22 | python-version: "3.10.11" |
16 | 23 |
|
17 | | - - name: Install dependencies # Install dependencies |
| 24 | + - name: Install dependencies |
18 | 25 | run: | |
19 | 26 | python -m pip install --upgrade pip |
20 | | - pip install Flask flake8 pytest |
| 27 | + pip install -r requirements.txt |
| 28 | +
|
| 29 | + - name: Run tests |
| 30 | + run: | |
| 31 | + # You can use pytest or any other testing framework |
| 32 | + pytest |
21 | 33 |
|
22 | | - - name: Lint with Flake8 |
23 | | - run: flake8 app.py |
| 34 | + deploy: |
| 35 | + runs-on: windows-latest |
| 36 | + needs: build |
| 37 | + if: github.ref == 'refs/heads/main' # Deploy only from the main branch |
24 | 38 |
|
25 | | - - name: Run unit tests |
26 | | - run: python test_app.py |
| 39 | + steps: |
| 40 | + - name: Checkout code |
| 41 | + uses: actions/checkout@v2 |
| 42 | + |
| 43 | + - name: Deploy to Windows Server |
| 44 | + run: | |
| 45 | + echo "Deploying to the Windows server..." |
| 46 | + # Replace the following command with your deployment script |
| 47 | + # Example: Using PowerShell to invoke a deployment script |
| 48 | + $session = New-PSSession -ComputerName your_server -Credential (Get-Credential) |
| 49 | + Invoke-Command -Session $session -ScriptBlock { |
| 50 | + cd "C:\path\to\your\app" |
| 51 | + git pull |
| 52 | + # Optionally restart your Flask service or application |
| 53 | + Stop-Service -Name "your_flask_service" -Force |
| 54 | + Start-Service -Name "your_flask_service" |
| 55 | + } |
| 56 | + Remove-PSSession -Session $session |
0 commit comments