Day#9 Installing Forgejo and native Forgejo Runner

Today I installed Forgejo and configured its native runner from scratch. Initially I also installed Woodpecker CI, but it turned out unnecessary.
Here’s the full record of actions.

mariusz
mariusz
20 posts
2 followers

Forgejo installation

Installed Forgejo manually from binary:

wget -O forgejo CODEBERG_PAGE/forgejo/forgejo/releases/download/v11.0.1/forgejo-11.0.1-linux-amd64
chmod +x forgejo
mkdir -p custom/conf custom/data
vim custom/conf/app.ini
./forgejo web --config ~/custom/conf/app.ini

Forgejo runs under a dedicated system user forgejo, with $HOME at /home/forgejo.
Accessible at: forgejo.local:3000


Forgejo Runner setup

Downloaded and installed the runner:

export RUNNER_VERSION=$(curl -s FORGEJO_PAGE/api/v1/repos/forgejo/runner/releases/latest | jq .name -r | cut -c 2-)
wget -O forgejo-runner FORGEJO_PAGE/forgejo/runner/releases/download/v\${RUNNER_VERSION}/forgejo-runner-\${RUNNER_VERSION}-linux-amd64
chmod +x forgejo-runner
cp forgejo-runner /usr/local/bin

Created a system user:

sudo useradd --system --home-dir /home/runner --shell /usr/sbin/nologin runner

Config generation

As user runner:

sudo su - runner
forgejo-runner generate-config > config.yml

Edited config.yml:

  • container.docker_host = "automount"
  • labels = ["docker:docker://node:20-bookworm"]

Runner registration

In Forgejo UI:
Admin → Actions → Runners → Create new runner

Copied the token.

Back in terminal, still as user runner:

forgejo-runner register

Filled prompts:

  • URL: forgejo.local:3000
  • token: *(from UI)*
  • name: local-runner
  • labels: docker:docker://node:20-bookworm

Runner registered successfully. File .runner created.


Testing

Created a repo with a basic workflow:

---
on: push
jobs:
  say-hello:
    runs-on: docker
    steps:
      - run: echo "Hello from Forgejo Runner!"

Pushed. The runner pulled the Docker image, executed the step, and returned logs successfully.


Backup to GitHub

To keep an external copy of the repository, I added a workflow that pushes the current repo and all tags to GitHub on each change to main.

# .forgejo/workflows/backup-to-github.yml

name: Backup to GitHub

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  backup:
    runs-on: docker
    container:
      image: alpine/git
      options: --add-host=forgejo.local:192.168.100.15
    steps:
      - name: Clone from Forgejo and push to GitHub
        env:
          GH_TOKEN: \${{ secrets.GH_TOKEN }}
        run: |
          git clone --no-checkout http://forgejo.local:3000/mariusz/TIn.git
          cd TIn
          git remote add github https://mabalew:$GH_TOKEN@github.com/mabalew/TIn.git
          git push github HEAD:refs/heads/main
          git push github --tags

Requires setting a personal GitHub token (GH_TOKEN) with repo access.


Notes

  • The Forgejo Runner integrates smoothly with the Forgejo UI.
  • No need for separate CI tooling like Woodpecker in my setup.
  • Backup to GitHub is handled via Forgejo Actions.
  • Entire system remains local and controlled.

Opublikowano

w

,

przez

Komentarze

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *