image: debian:12-slim

stages:
  - build
  - deploy

build:
  image: klakegg/hugo:alpine-ci
  stage: build
  script:
    - hugo
  artifacts:
    paths:
      - public
    expire_in: 1 week



deployment:
  stage: deploy
  only:
    - main
  before_script:
    - apt-get update -y && apt-get install openssh-client rsync -y
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:
    - rsync -rv -e 'ssh -p 18775' --delete ./public/ www-user@5.181.49.80:/var/www/janw.name/
