name: Deploy to Shuttle

on:
  push:
    branches: [ master ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '22'

      - name: Cache Node.js modules
        uses: actions/cache@v3
        with:
          path: ~/.npm
          key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.OS }}-node-

      - name: Build Frontend
        run: |
          cd frontend
          npm i -g @angular/cli
          npm ci
          ng build

      - uses: shuttle-hq/deploy-action@v2
        with:
          shuttle-api-key: ${{ secrets.SHUTTLE_API_KEY }}
          project-id: proj_01JNH9KPMRS34FKC2NHWQ5YNNB
          secrets: |
            SMTP_MAIL = '${{ secrets.SMTP_MAIL }}'
            SMTP_SECRET = '${{ secrets.SMTP_SECRET }}'
            SMTP_PROVIDER = '${{ secrets.SMTP_PROVIDER }}'