Skip to main content

Forgejo

forgejo-logo.png

Forgejo

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. To to so, you must configure a web hook in the repository so that push events can trigger the host building and serving static web pages.

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.

  • Go to the Settings page of the repository you want to publish.
  • Select the Webhooks tab.
  • Click Add Webhook and choose the Forgejo hook type.
  • Fill the form :
    • Target URL : enter https://fsp.frog-collective.com (FSP stands for Forgejo Static Pages)
    • HTTP Method: select POST
    • Post content type: select application/json
    • Secret: For now, you must ask the secret to someone who knows it. Write on the IT channel on Discord, or send a mail to admin@collectivit.org
    • Trigger On: select push events
    • Branch filter: you probably want to enter main here.
    • Authorization header: Leave blank
  • Click Add webhook

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: 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.