kind: pipeline
name: default
steps:

  - name: fetch-npm-deps
    image: node
    commands:
      - npm install

  - name: fetch-clojure-deps
    pull: always
    image: clojure:tools-deps
    volumes:
      - name: cache
        path: /drone/cache/
    commands:
      - ls -la /drone/cache/.m2
      - clj -Sdeps '{:mvn/local-repo "/drone/cache/.m2/repository"}' -P -M:shadow-cljs-run

  - name: build-clojure
    pull: always
    image: clojure:tools-deps
    depends_on:
      - fetch-clojure-deps
      - fetch-npm-deps
    volumes:
      - name: cache
        path: /drone/cache/
    commands:
      - ls -la /drone/cache/.m2
      - clj -Sdeps '{:mvn/local-repo "/drone/cache/.m2/repository"}' -Mshadow-cljs-run release app --debug

  # - name: deploy-site
  #   pull: True
  #   image: appleboy/drone-scp
  #   depends_on:
  #     - build-clojure
  #   settings:
  #     host: blog.digitaloctave.com
  #     port: 22
  #     username:
  #       from_secret: ssh_user
  #     key:
  #       from_secret: ssh_key
  #     target: /var/www/portfolio/${DRONE_COMMIT_SHA:0:10}/
  #     source: /drone/src/development/resources/public/*
  #     strip_components: 5

  - name: build-static-blog
    pull: always
    image: clojure:tools-deps
    depends_on:
      - fetch-clojure-deps
      - fetch-npm-deps
    volumes:
    - name: cache
      path: /drone/cache/
    commands:
      - ls -la /drone/cache/.m2
      - clj -M:blog:shadow-cljs-run release blog
      #- clj  -Sdeps '{:mvn/local-repo "/drone/cache/.m2/repository"}' -Mshadow-cljs-run release app --debug

  - name: deploy-static-blog
    pull: True
    image: appleboy/drone-scp
    depends_on:
      - build-static-blog
    settings:
      host: blog.digitaloctave.com
      port: 22
      username:
        from_secret: ssh_user
      key:
        from_secret: ssh_key
      target: /var/www/new-blog/
      source: /drone/src/bases/do-blog/resources/public/*
      strip_components: 6

  # - name: promote-deployed-site
  #   pull: True
  #   image: appleboy/drone-ssh
  #   depends_on:
  #     - deploy-site
  #   settings:
  #     host: blog.digitaloctave.com
  #     port: 22
  #     username:
  #       from_secret: SSH_USER
  #     key:
  #       from_secret: SSH_KEY
  #     port: 22
  #     command_timeout: 5m
  #     script:
  #       - cd /var/www/portfolio/
  #       - rm /var/www/portfolio/promoted
  #       - ln -s /var/www/portfolio/${DRONE_COMMIT_SHA:0:10} /var/www/portfolio/promoted

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