This site uses Forgejo Actions to automatically build and deploy whenever changes are pushed. The repository is named pages, which is required for Codeberg Pages to serve it at the canonical URL.

The source files live in the main branch, and the workflow builds the Hugo site and pushes the resulting HTML to a pages branch. After the first deployment, you need to change the default branch to pages in the repository settings.

Here’s the workflow configuration at .forgejo/workflows/deploy.yml:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Deploy Hugo site to Pages

on:
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build:
    runs-on: codeberg-small
    
    steps:
      - name: Checkout repository
        uses: https://code.forgejo.org/actions/checkout@v4
        with:
          submodules: recursive
          fetch-depth: 0
      
      - name: Install Hugo
        run: |
          HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep '"tag_name"' | sed -E 's/.*"v([^"]+)".*/\1/')
          echo "Detected Hugo version: ${HUGO_VERSION}"
          
          if [ -z "$HUGO_VERSION" ]; then
            echo "Failed to detect Hugo version, using fallback v0.154.5"
            HUGO_VERSION="0.154.5"
          fi
          
          # Try to download and install Hugo from GitHub releases
          if wget -O hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb 2>/dev/null && sudo dpkg -i hugo.deb 2>/dev/null; then
            echo "Successfully installed Hugo v${HUGO_VERSION} from GitHub"
          else
            echo "Failed to install Hugo from GitHub, falling back to distro package"
            sudo apt-get update
            sudo apt-get install -y hugo
          fi
          
          hugo version
      
      - name: Build site
        run: hugo --minify
      
      - name: Deploy to pages branch
        run: |
          cd public
          git init
          git config user.name "Forgejo Actions"
          git config user.email "actions@noreply.codeberg.org"
          git add .
          git commit -m "Deploy from ${GITHUB_SHA}"
          git push -f https://token:${GITHUB_TOKEN}@codeberg.org/${GITHUB_REPOSITORY}.git HEAD:pages
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_SHA: ${{ github.sha }}
          GITHUB_REPOSITORY: ${{ github.repository }}

The workflow automatically fetches the latest Hugo version from GitHub’s API. If the API is unavailable or rate-limited, it falls back to a known working version (v0.154.5). If the download or installation fails for any reason, it falls back to the Hugo package from the distribution’s repository. This multi-tiered fallback ensures deployments always succeed.


References: