The following instructions depend on the new git-pages server for Codeberg Pages and can currently only be used on sites which are hosted under our codeberg.page domain, and not with sites that should be served from custom domains.
Follow the old instructions for legacy v2 sites if you would like to deploy to a custom domain.
Git-pages has an associated Forgejo Action that can be used to automatically deploy your website from a static site generation tool. You can use any such tool you like: git-pages does not privilege any particular publishing system over others.
If you already use a static site generator and/or already use Forgejo Actions, using the pre-made Forgejo Action is by far the simplest and most efficient way to publish your site to Codeberg Pages.
To use it, simply add it as a final step to your workflow:
- uses: https://codeberg.org/git-pages/action@v2
with:
site: "https://${{ forge.repository_owner }}.codeberg.page/repository-name/"
token: ${{ forge.token }}
source: _site/
Replace repository-name in the site parameter with the name of your repository.
If your repository is also called pages, you can also omit the repository name and deploy directly to the site https://username.codeberg.page/.
The source parameter should point to the directory (relative to the root, after all previous steps in your workflow) where your site generator has put the generated version of your site.
This directory can also contain the 404.html and _redirects files to customize your site’s behaviour, as described in the advanced documentation.
The token will automatically be filled by Forgejo Actions with a secret token, which in turn will automatically be recognized by git-pages as authorizing this workflow to publish to this site.
If you use branches to test out new features, write draft blog posts, etc., you should either limit the whole workflow, or this step only, to pushes to a default branch (usually main or master) to ensure that only finalized content is published to your site.
To do this, either add a on.push.branches list to the whole workflow, or add an if condition to the step (or to the whole job) like this:
if: ${{ forge.ref == 'refs/heads/main'}}
This will limit deploys so they only happen when CI is triggered by a push to the main branch.