Files
PolyWeather/.github/workflows/ci.yml
T
2026-05-25 05:59:41 +08:00

84 lines
2.0 KiB
YAML

name: CI
on:
push:
branches:
- main
pull_request:
jobs:
python-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: Ruff
run: python -m ruff check .
- name: Pytest
run: python -m pytest
frontend-quality:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Business state tests
run: npm run test:business
- name: Build
run: npm run build
docker-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t polyweather-ci .
deploy:
needs: [python-quality, frontend-quality, docker-build]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Deploy to VPS
run: |
mkdir -p ~/.ssh
echo "${{ secrets.VPS_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh -o StrictHostKeyChecking=accept-new ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "
cd /root/PolyWeather
git fetch origin main && git reset --hard origin/main
docker compose down
docker compose up -d --build
sleep 10
curl -s http://localhost:8000/healthz
"