name: Download VM Deploy
on:
  push:
    branches:
      - main
    paths:
      - "api/download/**"
  workflow_dispatch:

jobs:
  deploy:
    name: Deploy app
    runs-on: ubuntu-latest
    if: github.repository == 'fontsource/fontsource'
    defaults:
      run:
        working-directory: api/download

    steps:
      - name: checkout
        uses: actions/checkout@v4

      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Install
        run: bun install

      - name: Run lints
        run: bun run ci:lint

      - uses: superfly/flyctl-actions/setup-flyctl@master
      - run: flyctl deploy --remote-only
        env:
          FLY_API_TOKEN: ${{ secrets.FLY_DOWNLOAD_TOKEN }}
