learning-woodpecker-ci

Using Woodpecker CI self-hosted with Codeberg self-hosted runner.

runner

https://forgejo.org/docs/next/admin/actions/#forgejo-runner

Forgejo give almost everything that you need

wget -O forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v3.3.0/forgejo-runner-3.3.0-linux-amd64
chmod +x forgejo-runner
wget -O forgejo-runner.asc https://code.forgejo.org/forgejo/runner/releases/download/v3.3.0/forgejo-runner-3.3.0-linux-amd64.asc
gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710
gpg --verify forgejo-runner.asc forgejo-runner

But doesn't tell you that you need to register too

./forgejo-runner register
  • Forgejo instance URL: https://codeberg.org
  • Runner token: Get at your organization "Settings > Actions > Runners"
  • Rest is up to you to fill or not

Start runner with:

sudo ./forgejo-runner daemon

application

  • Create an application at your organization "Settings > Applications"
  • Redirect URIs: http://<your-ip>:<your-port>/authorize
    • I'm using http just for learning
    • Remember to have your modem configured to accept connection to your port.
    • An example of redirect uri: http://127.0.0.1:8000/authorize.

After creation, it will give you a "Client ID" and "Client Secret" (save it to use with woodpecker-ci).

woodpecker-ci

Using there docker-compose as base
And instruction for forgejo
Add more server configurations

  • Replace
    • GITHUB by GITEA
    • 8000:8000 by <your-port>:8000
    • ${WOODPECKER_HOST} by http://<your-ip>:<your-port>
    • ${WOODPECKER_GITHUB_CLIENT} by the application "Client ID"
    • ${WOODPECKER_GITHUB_SECRET} by the application "Client Secret"
    • ${WOODPECKER_AGENT_SECRET} by the random string generated by openssl rand -hex 32
  • Add
    • WOODPECKER_GITEA_URL with https://codeberg.org
    • Directory to store woodpecker server data after woodpecker-server-data:
    • Directory to store woodpecker agent data after woodpecker-agent-config:
version: '3'

services:
  woodpecker-server:
    image: woodpeckerci/woodpecker-server:latest
    ports:
      - 8000:8000
    volumes:
      - woodpecker-server-data:/var/lib/woodpecker/
    environment:
      - WOODPECKER_OPEN=true
      - WOODPECKER_HOST=${WOODPECKER_HOST}
      - WOODPECKER_GITEA=true
      - WOODPECKER_GITEA_URL=https://codeberg.org
      - WOODPECKER_GITEA_CLIENT=${WOODPECKER_GITHUB_CLIENT}
      - WOODPECKER_GITEA_SECRET=${WOODPECKER_GITHUB_SECRET}
      - WOODPECKER_AGENT_SECRET=${WOODPECKER_AGENT_SECRET}

  woodpecker-agent:
    image: woodpeckerci/woodpecker-agent:latest
    command: agent
    restart: always
    depends_on:
      - woodpecker-server
    volumes:
      - woodpecker-agent-config:/etc/woodpecker
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - WOODPECKER_SERVER=woodpecker-server:9000
      - WOODPECKER_AGENT_SECRET=${WOODPECKER_AGENT_SECRET}

volumes:
  woodpecker-server-data:
  woodpecker-agent-config:

docker

sudo docker compose up
  • When ready access your woodpecker-ci http:://<your-ip>:<your-port>.
    • If you are on same machine as woodpecker-ci, use http://127.0.0.1:<your-port> instead.
    • If you are on same lan as woodpecker-ci, use http://<machine-lan-ip>:<your-port> instead.
  • When attempting to login, it will redirect you to codeberg and ask you permission.
  • After accepting, codeberg will redirect you to http:://<your-ip>:<your-port>.
    • if you are on same machine as woodpecker-ci, after failing change it to http://127.0.0.1:<your-port>.
    • if you are on same machine as woodpecker-ci, after failing change it to http://<machine-lan-ip>:<your-port>.

references

https://codeberg.org/dkarakasilis/self-hosted-ci