image: shockrah/website:latest

stages:
  - build
  - deploy


build-site:
  only:
    refs:
      - master

  stage: build

  script:
    - hugo version
    - hugo 

  artifacts:
    expire_in: 10 mins 
    paths: 
      - "public"

deploy-vps:
  only:
    refs:
      - master

  stage: deploy

  # Setup the SSH Key in required for VPS deployment first
  before_script:
    - eval "$(ssh-agent -s)"
    - echo "${SSH_PRIVATE_KEY}" | ssh-add - > /dev/null

    - mkdir -p ~/.ssh/
    - chmod 700 ~/.ssh/

    - ssh-keyscan $VPS_HOST 2>&1 >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts

    # This is all fine because its just static html w/ no scripts :^)
  script:
    - ssh root@shockrah.xyz "rm -rf /var/www/website"
    - scp -r public/ root@shockrah.xyz:/var/www/website/

deploy-neocities:
  # This might get really ugly with neocities so hang on a while before we bother
  # trying to figure how tf we deploy this thing
  only:
    refs:
      - neocities

  stage: deploy

  script:
    # First the html
    - bash upload.sh -h
    # then we do the media files
    - bash upload.sh -M



