kind: pipeline
type: ssh
name: install dependencies

server:
  host: warframe.center
  user: webmaster
  ssh_key:
    from_secret: ssh_private_key

clone:
  disable: true

steps:
- name: fetch remote
  commands:
  - cd /home/webmaster/warframe-center && git fetch --all && git reset --hard origin/monorepo
- name: install dependencies
  commands:
  - export PATH=$PATH:/home/webmaster/.nvm/versions/node/v16.14.2/bin
  - cd /home/webmaster/warframe-center && npm install

trigger:
  branch:
  - monorepo

---

kind: pipeline
type: docker
name: build

clone:
  disable: true

steps:
- name: bulid frontend
  image: node:16
  environment:
    SSH_PRIVATE_KEY:
      from_secret: ssh_private_key
    MONGODB_URI:
      from_secret: MONGODB_URI
  commands:
  - git clone -b monorepo https://git.radner.ru/anatolykopyl/warframe-center.git
  - cd warframe-center
  - npm install
  - npm run build -w app
  - mkdir ~/.ssh
  - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
  - chmod 400 ~/.ssh/id_rsa
  - scp -o StrictHostKeyChecking=no -r ./app/.next webmaster@warframe.center:~/warframe-center/app
  - |
    ssh -o StrictHostKeyChecking=no webmaster@warframe.center '
      [ -s ~/.nvm/nvm.sh ] && source ~/.nvm/nvm.sh &&
      nvm use default &&
      pm2 restart warframe-center-app-3000
    '

depends_on:
- install dependencies

trigger:
  branch:
  - monorepo
