pipeline:
  build:
    image: node:6.7
    pull: true
    commands:
      - make build
      - make github-pages
    when:
      branch: master

  npm:
    image: plugins/npm
    username: $NPM_USERNAME
    password: $NPM_PASSWORD
    email: support@presslabs.com
    secrets: [ NPM_USERNAME, NPM_PASSWORD ]
    when:
      branch: master

  github_pages:
    image: appleboy/drone-git-push
    force: true
    branch: gh-pages
    remote: git@github.com:/Presslabs/react-particles-icons.git
    secrets:
      - GIT_PUSH_SSH_KEY
    commit_message: "Update static page"
    when:
      branch: master

clone:
  default:
    image: plugins/git
    recursive: true
    group: clone

  presslabs-org:
    image: alpine/git
    group: clone
    commands:
      # write the ssh key to disk
      - mkdir /root/.ssh
      - echo -n "$GIT_PUSH_SSH_KEY" > /root/.ssh/id_rsa
      - chmod 600 /root/.ssh/id_rsa

      # add github to known hosts
      - touch /root/.ssh/known_hosts
      - chmod 600 /root/.ssh/known_hosts
      - ssh-keyscan -H github.com > /etc/ssh/ssh_known_hosts 2> /dev/null

      # clone presslabs-org
      - git clone -b prod git@github.com:/PressLabs/presslabs-org.git /drone/src/presslabs-org
    secrets:
      - GIT_PUSH_SSH_KEY
    when:
      branch: master

pipeline:
  build:
    image: node:8.9.4
    pull: true
    group: build
    commands:
      - make build
    when:
      branch: master

  build-docs:
    image: alpine:3.7
    commands:
      - mkdir -p /drone/src/presslabs-org/wp-content/root/react-particles-icons/
      - rm -rf /drone/src/presslabs-org/wp-content/root/react-particles-icons/*
      - mv demo/* /drone/src/presslabs-org/wp-content/root/react-particles-icons
    when:
      branch: master

  update-presslabs-org:
    image: appleboy/drone-git-push
    branch: prod
    group: publish
    commit: true
    path: /drone/src/presslabs-org
    commit_message: "[docs] Update react-particles-icons demo"
    remote: git@github.com:/Presslabs/presslabs-org.git
    secrets:
      - GIT_PUSH_SSH_KEY
    when:
      branch: master

  npm:
    image: plugins/npm
    email: support@presslabs.com
    group: publish
    secrets: [ NPM_USERNAME, NPM_PASSWORD ]
    when:
      branch: master

Deploy demo page on presslabs.org
Deploy demo page on presslabs.org
