name: publish

on:
  push:
    branches:
      - main

jobs:
  publish:
    runs-on: ubuntu-latest
    env:
      SSH_PRIVATE_KEY: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
      TZ: Europe/Berlin
    steps:
      - name: checkout
        uses: actions/checkout@v4
        with:
          submodules: recursive
 
      - name: Hugo setup
        uses: xmengnet/actions-hugo@v3

      - name: build project
        run: |
          hugo build

      - name: upload artifact
        uses: https://code.forgejo.org/forgejo/upload-artifact@v4
        with:
          path: _site

      - name: deploy
        run: |
          apt-get update && apt-get install -y rsync
          eval $(ssh-agent -s)
          echo "$SSH_PRIVATE_KEY" | ssh-add -
          mkdir ~/.ssh
          ssh-keyscan ifsr.de > ~/.ssh/known_hosts
          rsync -rvh --progress --delete --chmod=ugo=rwX public/ ese-deploy@ifsr.de:

