---
kind: pipeline
type: docker
name: ci-check

trigger:
  branch:
    - develop
  event:
    - push
    - pull_request

steps:
  - name: install
    image: node:22-alpine
    commands:
      - npm ci

  - name: typecheck
    image: node:22-alpine
    commands:
      - npx tsc --noEmit
    depends_on:
      - install

  - name: build
    image: node:22-alpine
    commands:
      - npm run build
    environment:
      VITE_API_BASE_URL: https://api.test.bogazicidenizcilik.com
    depends_on:
      - install

---
kind: pipeline
type: ssh
name: deploy-test

trigger:
  branch:
    - test
  event:
    - push

server:
  host:
    from_secret: server_host
  user:
    from_secret: server_user
  ssh_key:
    from_secret: server_ssh_key

steps:
  - name: deploy
    commands:
      - cd /opt/projects/bogazici/corporate-admin/test/admin
      - bash scripts/deploy-test.sh

---
kind: pipeline
type: ssh
name: deploy-prod

trigger:
  branch:
    - main
  event:
    - push

server:
  host:
    from_secret: server_host
  user:
    from_secret: server_user
  ssh_key:
    from_secret: server_ssh_key

steps:
  - name: deploy
    commands:
      - cd /opt/projects/bogazici/corporate-admin/prod/admin
      - bash scripts/deploy-prod.sh
