Over the last year or so, I've been trying to switch some of my "US big tech" products/services to smaller preferably European alternatives. It started with Twitter → Mastodon (then on to Bluesky/Eurosky) back when Elon Musk bought twitter and a bunch of people were laid off. Later I replaced my Kindle with a Pocketbook, Google Drive with Jottacloud, Strava with Fitpub, and I moved many of my hobby projects for GitHub to Codeberg. Migrating codebases was easy, but migrating GitHub Actions pipelines and cloud infrastructure was less trivial.
A couple of my hobby projects, including this very website, were hosted on GitHub pages. Codeberg offers a similar alternative "Codeberg pages". Here is how I migrated this site over.
DNS
I updated the DNS CNAME record from GitHub pages (e.g. christianfosli.github.io) to just "codeberg.page", added a TXT record for git-pages authorization (in my case TXT _git-pages-forge-allowlist.www.christianfosli.com = https://codeberg.org/christianfosli/pages.git), and removed the now stale static/CNAME file from the repo (used for custom domain verification in GitHub Actions).
GitHub Actions to Woodpecker CI
The two most common CI/CD tools used on Codeberg are Forgejo Actions and Woodpecker CI. I was not at all sure what to pick, but decided to try out Woodpecker CI. I had already followed the documented process for obtaining access to Codeberg's Woodpecker CI instance due to migrating another hobby project.
I needed to give woodpecker access to deploy to Codeberg pages, so I created an access token (in Codeberg settings -> applications) with read:user and write:repository access.
Next I signed in to ci.codeberg.org, enabled woodpecker CI for my pages repo, and added the access token generated above as a secret with the name CB_ACCESS_TOKEN. Needing this secret was kind of a let-down. It looks like this part would be more integrated with Forgejo Actions. Oh well.
Next I replaced my .github/workflows/build-deploy.yaml workflow with a .woodpecker/deploy.yaml variant:
when:
- event: push
branch: ${CI_REPO_DEFAULT_BRANCH}
# Clone recursively to fully clone the themes given as Git submodules
clone:
git:
image: woodpeckerci/plugin-git
settings:
recursive: true
steps:
build:
image: alpine:edge
commands:
- apk add --no-cache zola
- zola build --base-url https://www.christianfosli.com --output-dir out
deploy:
image: codeberg.org/gedankenstuecke/git-pages-woodpecker-plugin:v6
settings:
TOKEN:
from_secret: CB_ACCESS_TOKEN
UPLOAD_DIR: out
SITE_URL: http://www.christianfosli.com
And pushed my changes. The build step here is specific for my pages (using Zola) while the deploy step should work for most static sites. I needed to use a http:// url to start with, and then once the site was live and a TLS certificate had been provisioned I switched to HTTPS:
--- a/.woodpecker/deploy.yaml
+++ b/.woodpecker/deploy.yaml
@@ -22,4 +22,4 @@ steps:
TOKEN:
from_secret: CB_ACCESS_TOKEN
UPLOAD_DIR: out
- SITE_URL: http://www.christianfosli.com
+ SITE_URL: https://www.christianfosli.com
I'm not 100% happy with the pipeline, but it gets the job done. Hopefully is useful for future me (or you) the next time we want to migrate something from GitHub Actions+Pages to Codeberg Pages+Woodpecker CI 😀.
Have a look at my pages repo and the commit log there for more details.