Forgejo

forgejo-logo.png

Publish static sites

It is possible to easily configure a Forgejo repository to be built and published on any unused subdomain of frog-collective.com every time a commit is pushed to it. To do so, you must configure a web hook in the repository so that push events can trigger the build and publishing of your static web pages.

Configuration

You must have the administration rights on the repository you want to publish. To publish a repository, you must first configure a web hook on it.

Now that the web hook is configured, add a file at the root of your repository named .static-pages.yml with the following content  :

site_name: peter.frog-collective.com # The hostname where the website will be available
build_command: nox -r -s build # The command to run to build your pages
build_directory: build # The folder relative to the repository root where the pages are, once built

Add it, commit on the branch you entered in the Branch filter field when configuring the web hook, and push. After a while, your website should appear at the configured address.

Never leak the web hook secret : as the pages are built by running a custom command, having access to this secret means being able to run arbitrary code on the CollectivIT production servers. For the same reason, be cautious when you configure your build commands.

The environment in which the build is launched on the static pages server is limited. You can use bash, python and nox. Don't expect other software to be available, as it is subject to change without notice. If you have other build dependencies, nox is a good way to go to create virtual environments to install them, and nodeenv can be used to create nodejs virtualenvs if you need npm.

For now it is not possible to build different branches to different domains, but it could be easily added, fill a ticket on https://git.frog-collective.com/collectivit/collectivit/issues if you want that.

For now, only public repositories can be published. This limitation will be avoided in the future by creating a specific user for the page build service : check https://git.frog-collective.com/collectivit/collectivit/issues/81

Troubleshooting

If your website doesn't go online in a reasonable amount of time after you pushed, first, check that the hook is sent and received :

If the Body section contains {"status": "queued"} but nothing gets online, the hook is received, but the build and publish fail at some point. In this case :


Revision #15
Created 2 June 2024 21:41:23 by Corentin
Updated 2 June 2024 23:54:15 by Corentin