Skip to content

requirments

requirments #2

Workflow file for this run

name: Python application CI/CD
on: [push, pull_request]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.12.1
uses: actions/setup-python@v2
with:
python-version: 3.12.1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest (unit tests)
run: pytest test_app.py
- name: Run integration tests
run: pytest test_integration.py
- name: Run end-to-end tests
run: pytest test_e2e.py
- name: Deploy to AWS EC2 (Staging Environment)
if: github.ref == 'refs/heads/main'
uses: easingthemes/ssh-deploy@v2.1.5
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
REMOTE_PORT: ${{ secrets.REMOTE_PORT }}
SOURCE: "."
TARGET: "instance"
- name: Restart Application
if: github.ref == 'refs/heads/main'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.REMOTE_PORT }}
script: |
pkill -f 'python app.py'
nohup python app.py &