# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/

name: Fly Deploy
on:
  push:
    branches: [main]

jobs:
  test:
    name: Run Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v5
        with:
          version: "latest"
      - run: uv python install 3.13
      - run: uv sync --extra dev
      - run: uv run pytest tests/ -n auto --tb=short

  deploy:
    name: Deploy app
    runs-on: ubuntu-latest
    needs: test
    environment: prod
    concurrency: deploy-group
    steps:
      - uses: actions/checkout@v4
      - uses: superfly/flyctl-actions/setup-flyctl@master
      - run: flyctl deploy --remote-only --strategy bluegreen
        env:
          FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
