Deploying hugo to nginx webroot from remote repository

Hi,

I am hosting my code for my hugo website on forgejo (git version management software), so that other users can make changes to the website without accessing my server directly.

My website rebuilds itself everytime someone pushes to it with actions, like this: Host on Codeberg Pages .

I am not using any virtualization software like docker or podman, but my workflow actions run as a non-priviledged user called “runner”.

How can I download the generated artifacts - in this case the public folder of my website, from forgejo to my NGINX web root?

I already tried `actions/download-artifact`, but for this to work the runner user would have to have permissinon to write to my nginx web root. I want to avoid this.

I tried something similar with rsync, but the “runner” user would have to have access to an ssh key to access my server. This also does not seem that save, right?

What other options do I have? Is there a good way to do this?

The link you provided renders a 404. Is Codeberg Pages building the site for you? You could use a similar action to copy the public directory elsewhere. I don’t use Codeberg, but am using a post-receive hook to clone my repository, and running hugo on it, like so:

#!/bin/bash -l
GIT_REPOSITORY=/path/to/my/repository
TMP_GIT_CLONE=/tmp/git/website
WWW_ROOT=/var/www/my_site/

git clone $GIT_REPOSITORY $TMP_GIT_CLONE
cd $TMP_GIT_CLONE
hugo -d $WWW_ROOT
rm -rf $TMP_GIT_CLONE
exit