Lightweight CI/CD with GitHub Actions and a Self-Hosted Runner
Build and deploy on your own server with a self-hosted runner: setup, a sample workflow and the security warnings that really matter.

Table of contents
GitHub Actions is free for public repositories and runs builds on GitHub’s machines, but there is another option: your own runner on your own server, so builds and deploys happen right where the site runs.
Setting up the runner
In the repository, go to Settings → Actions → Runners → New self-hosted runner. GitHub shows the exact commands there (download, configure and a one-time token):
./config.sh --url https://github.com/ORG/REPO --token XXXXXXXX
./run.sh # trial run
sudo ./svc.sh install # install as a permanent service
sudo ./svc.sh start
A sample workflow
The file .github/workflows/deploy.yml:
name: deploy
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- run: docker compose build
- run: docker compose up -d
- run: docker image prune -f
Every push to main is built and started on your own server, with no images shipped between machines.
A serious security warning
Every job means running arbitrary code on your server. Three lines of defence:
- Keep the repository private, and give write access only to collaborators you trust.
- Don’t run the runner as root; membership of the docker group is enough to build and run containers.
- Never attach a self-hosted runner to a public repository: anyone who opens a pull request gets their code executed on your server. GitHub’s own documentation warns about exactly this risk.
Sources
- Self-hosted runner documentation: docs.github.com/actions/hosting-your-own-runners



Comments
No comments yet. For technical questions, include the details (OS version, the exact error and the command you ran) to get a precise answer.