Moving from Github Pages to Codeberg Pages


In my quest to slowly move away from Github one big hurdle is still remaining: Moving the sites I currently host on Github Pages to Codeberg Pages.

Here is the step by step guide that worked for me (custom domain)

  1. Move the repository to Codeberg (I am using my own migrate-github-to-codeberg/)
  2. Do not forget to set the new remote if you still have a local git repository git remote set-url origin git@codeberg.org:YOUR_USERNAME/YOUR_REPO.git
  3. Enable Codeberg Actions in SettingsUnitsEnable Actions1
  4. For the custom domain add the following DNS record: _git-pages-forge-allowlist.www.example.org TXT https://codeberg.org/username/repository.git2
  5. Add a .forgejo/workflows/publish.yaml file with content roughly like this:
name: Publish
on:
  push:
    branches: [main]
jobs:
  publish:
    runs-on: codeberg-small
    steps:
      - uses: actions/checkout@v6

      - name: Install Rust, WASM-Pack and build WASM
        run: |
          curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
          source ~/.cargo/env
          curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
          chmod +x build_all_wasm.sh && ./build_all_wasm.sh

      - name: Setup Node
        uses: https://code.forgejo.org/actions/setup-node@v4
        with:
          node-version: 20

      - name: Install dependencies
        run: npm install

      - name: Build site
        run: npm run build

      - uses: https://codeberg.org/git-pages/action@v2
        with:
          site: https://notes.simonschlegl.com/
          server: codeberg.page
          token: ${{ forgejo.token }}
          source: dist/

For me somehow codeberg-tiny was not available (?) so I went with codeberg-small

  1. Route the DNS to codeberg pages: CNAME codeberg.page.3
  2. (optional) Check via dig notes.simonschlegl.com that it actually points to codeberg.page.
  3. Donate to Codeberg: https://donate.codeberg.org/

Sources

Footnotes

  1. https://codeberg.org/actions/meta

  2. https://codeberg.org/git-pages/action

  3. https://codeberg.page/