Skip to content
Rosamund Mather

notes /

Deploying to Codeberg Pages

2 min · 346 words

For a variety of reasons, I wanted to move the repo and hosting for this blog away from a GitHub + Vercel workflow. My most obvious alternative seemed to be Codeberg: a Git platform run by a German non-profit association of the same name.

To be clear, this post isn’t about porting my repo from GitHub to Codeberg. The source code in the old was overall pretty stale, and private anyway, so I essentially decided to download the Markdown files that were my posts and start from scratch with Astro. Since this involves a build step, you have to create your own CI/CD pipeline, which you can do with Forgejo Actions.

Here are all the steps I took to put everything in place.

  • Created a repo called pages (I think this naming isn’t actually strictly necessary anymore, but I wanted to make it explicit). Note: the repo’s visibility has to be public.
  • Went to my domain provider and deleted the Vercel nameservers.
  • Added the following records for my domain:
Type Name Value
CNAME www codeberg.page
TXT _git-pages-forge-allowlist.www [repo url]
  • Went to Settings -> Units -> Overview in my repo and enabled Actions.
  • Created a new branch called pages in my local repo and checked it out. Ran the build command. Committed the contents of dist/.
  • In the repo root, I created a new directory, .forgejo/workflows/ and within it a new file, deploy.yaml, which I filled with the following:
name: Build and deploy
on:
	push:
		branches:
			- main

	workflow_dispatch:

concurrency:
	group: ${{ forgejo.workflow }}-${{ forgejo.ref }}
	cancel-in-progress: true

jobs:
	build_and_deploy:
		runs-on: codeberg-small
		env:
			SITE_URL: # add site url including https://
		steps:
			- name: Checkout
			uses: actions/checkout@v4

			- name: Set up Node
			uses: actions/setup-node@v4
			with:
				node-version: 22

			- name: Install and build
			working-directory: devblog  # the directory inside my project root
			run: |
				corepack enable
				pnpm install --frozen-lockfile
				pnpm build
				
			- name: Deploy
			uses: https://codeberg.org/git-pages/action@v2
			with:
				site: # add site url including https://
				server: codeberg.page
				token: ${{ forgejo.token }}
				source: devblog/dist/
  • Committed the file.
  • Clicked on the Actions tab of my repo and saw the job had failed, had to tweak the working-directory and source path (the correct version is above).
  • Re-committed, pipeline passed, website visitable!

The most painful part of it all was the DNS config. Forgejo Actions wasn’t actually my first choice; I’d wanted to deploy via a webhook, but for some reason my domain provider wasn’t having any of it. Finally I got it to propagate after a lot of testing. Running dig TXT _git-pages-forge-allowlist.www.<domain> @<nameserver> +short in my local console helped me troubleshoot and figure out whether the problem was the record itself, or something on the Codeberg side.