---
kind: pipeline
type: docker
name: seasoned build

platform:
  os: linux
  arch: amd64

volumes:
  - name: cache
    host:
      path: /tmp/cache

steps:
  - name: Load cached frontend packages
    image: sinlead/drone-cache:1.0.0
    settings:
      action: load
      key: yarn.lock
      mount: node_modules
      prefix: yarn-modules-seasoned
    volumes:
      - name: cache
        path: /cache

  - name: Frontend install
    image: node:24.13.1
    commands:
      - node -v
      - yarn --version
      - yarn

  - name: Cache frontend packages
    image: sinlead/drone-cache:1.0.0
    settings:
      action: save
      key: yarn.lock
      mount: node_modules
      prefix: yarn-modules-seasoned
    volumes:
      - name: cache
        path: /cache

  - name: Lint project using eslint
    image: node:24.13.1
    commands:
      - yarn lint
    failure: ignore

  - name: Frontend build
    image: node:24.13.1
    commands:
      - yarn build
    environment:
      ELASTIC:
        from_secret: ELASTIC
      ELASTIC_INDEX:
        from_secret: ELASTIC_INDEX
      SEASONED_API:
        from_secret: SEASONED_API
      SEASONED_DOMAIN:
        from_secret: SEASONED_DOMAIN

  - name: Build and publish docker image
    image: plugins/docker
    settings:
      registry: ghcr.io
      repo: ghcr.io/kevinmidboe/seasoned
      dockerfile: Dockerfile
      username:
        from_secret: GITHUB_USERNAME
      password:
        from_secret: GITHUB_PASSWORD
      tags: latest
    when:
      event:
        - push
      branch:
        - master

  - name: deploy
    image: appleboy/drone-ssh
    pull: true
    secrets:
      - ssh_key
    when:
      event:
        - push
      branch:
        - master
        - drone-test
      status: success
    settings:
      host: 10.0.0.54
      username: root
      key:
        from_secret: ssh_key
      command_timeout: 600s
      script:
        - /home/kevin/deploy/seasoned.sh

trigger:
  event:
    include:
      - push
      # - pull_request
---
kind: signature
hmac: 6f10b2871d2bd6b5cd26ddf72796325991ba211ba1eb62b657baf993e9d549c8

...
