workspace:
  base: /checkout
  path: data

pipeline:
  build:
    image: einar/hugo
    environment:
      - NGINX_UID=476
      - NGINX_GID=476
      - HUGO_ENV=production
    commands:
      - git lfs pull
      - hugo --destination /checkout/public
      - chown -R $NGINX_UID:$NGINX_GID /checkout/public/
      - rm -f /checkout/public/.gitadd /checkout/public/.gitignore
  deploy:
    image: einar/hugo
    commands:
      - rsync -aXHP --size-only --checksum --quiet /checkout/public/ /site/ --exclude .gitadd --exclude .gitignore
    volumes:
      - /srv/www/htdocs/dennogumi.org:/site
  notify:
    image: matrixcommander/matrix-commander:latest
    commands:
      - 'export MESSAGE="#### 🛈 CI pipeline report\n\n *CI Build for* $CI_REPO: **$CI_BUILD_STATUS**<br />*Commit author*: $CI_COMMIT_AUTHOR<br />*Commit*: [${CI_COMMIT_SHA:0:8}]($CI_BUILD_LINK) (branch $CI_COMMIT_BRANCH)"'
      - '/bin/python3 /app/matrix_commander/matrix-commander --markdown -s /data/store -c /data/credentials.json --message "$(echo -e $${MESSAGE})"'
    volumes:
      - /var/lib/matrix-commander-docker:/data
    when:
      status:
        - failure
        - success