Spaces:
Running
Running
| name: CI/CD | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| # ---------- CI: runs on every push & pull request ---------- | |
| ci: | |
| name: Build & test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: pip | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Smoke test (app imports without errors) | |
| run: python -c "import app; print('app imports OK')" | |
| - name: Verify Docker image builds | |
| run: docker build -t chatbot-lookupit . | |
| # ---------- CD: only on push to main, after CI passes ---------- | |
| deploy: | |
| name: Deploy to Lightsail | |
| needs: ci | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy over SSH | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.LIGHTSAIL_HOST }} | |
| username: ${{ secrets.LIGHTSAIL_USER }} | |
| key: ${{ secrets.LIGHTSAIL_SSH_KEY }} | |
| script: | | |
| cd ~/chatbot_lookupit | |
| git pull origin main | |
| bash deploy/update.sh | |