image: ubuntu:precise

cache:
  paths:
    - output/ # Node modules and dependencies

before_script:
  - apt-get update
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
  - eval $(ssh-agent -s)
  - ssh-add <(echo "$SSH_PRIVATE_KEY")
  - mkdir -p ~/.ssh
  - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

build:
  stage: build
  script:
    - apt-get install -y --force-yes build-essential python-dev python-pip
    - pip install --editable .
    - pelican content

  artifacts:
    untracked: true

deploy:
  stage: deploy
  dependencies:
    - build
  script:
    - scp -r output/* mazenod@192.168.100.59:~/public_html/
    - ssh mazenod@192.168.100.59 'find ~/public_html/ -type f -exec chmod -R 644 {} \;'
    - ssh mazenod@192.168.100.59 'find ~/public_html/ -type d -exec chmod -R 755 {} \;'
