This commit is contained in:
2026-03-20 17:04:35 +03:30
parent 8ca9d388d4
commit 3e6418b4e8
2 changed files with 192 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
name: Sensor Hub Service CI/CD
on:
push:
branches: [main]
paths:
- 'sensor-hub/**'
- 'sensor-hub/.github/workflows/sensor-hub.yml'
pull_request:
branches: [main]
paths:
- 'sensor-hub/**'
- 'sensor-hub/.github/workflows/sensor-hub.yml'
defaults:
run:
working-directory: sensor-hub
jobs:
test:
name: Lint & Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ['3.11']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-sensor-hub-${{ hashFiles('sensor-hub/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-sensor-hub-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest flake8
- name: Run lint
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Run tests
run: pytest --tb=short -q
deploy:
name: Deploy Sensor Hub Service
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /opt/myproject/sensor-hub
git pull origin main
sudo systemctl restart sensor-hub