Forgejo Actions example: Node.js tests, Docker build, and deployment into a dedicated CI Docker engine.
  • JavaScript 86.2%
  • Dockerfile 13.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-25 20:26:22 +00:00
.forgejo/workflows Remove unsupported Forgejo workflow permissions field 2026-11-11 17:00:38 +00:00
test Add Forgejo CI/CD example with tests, Docker build and verified deployment 2026-11-11 16:58:30 +00:00
.dockerignore Add Forgejo CI/CD example with tests, Docker build and verified deployment 2026-11-11 16:58:30 +00:00
.gitignore Add Forgejo CI/CD example with tests, Docker build and verified deployment 2026-11-11 16:58:30 +00:00
Dockerfile Add Forgejo CI/CD example with tests, Docker build and verified deployment 2026-11-11 16:58:30 +00:00
package.json Add Forgejo CI/CD example with tests, Docker build and verified deployment 2026-11-11 16:58:30 +00:00
README.md Update Forgejo hostname after migration [skip ci] 2026-11-25 20:26:22 +00:00
server.js Add Forgejo CI/CD example with tests, Docker build and verified deployment 2026-11-11 16:58:30 +00:00

Forgejo CI/CD example

CI / CD

A dependency-free Node.js 24 HTTP application with a working Forgejo Actions pipeline. GET / returns a greeting and version; GET /health reports health.

Pipeline

Every push to main, pull request, or manual run:

  1. Checks out the commit and runs four HTTP integration tests.
  2. Builds a Docker image tagged with that commit's SHA.
  3. Repeats the tests inside the built image.
  4. On main only, deploys the image as taznado-ci-cd-example and checks both Docker health status and the running application's response.

The demo deployment runs inside the runner's dedicated Docker-in-Docker engine. It persists between jobs, has no published host ports, and is not a public website. No registry credentials, deployment secrets, or host Docker socket are required. Pull requests build and test without replacing the demo. The single-job runner serializes execution. This simple demo replaces its container on deployment; it does not provide production rollback or zero downtime.

Run locally

With Node.js 24 or later:

npm test
npm start

With Docker:

docker build -t forgejo-ci-cd-example .
docker run --rm forgejo-ci-cd-example npm test
docker run --rm -p 3000:3000 forgejo-ci-cd-example

Open http://localhost:3000/ or /health.

Runner requirements

Enable Actions and register a runner with these labels:

runner:
  capacity: 1
  labels:
    - ubuntu-latest:docker://node:24-bookworm
    - docker:docker://docker:28-cli

The runner must execute jobs in a dedicated Docker engine and expose that engine to job steps through DOCKER_HOST. Use only trusted workflows with access to this engine. In this installation the runner is restricted to this repository. The ubuntu-latest label uses a Debian-based Node image, not a full GitHub runner.

To inspect the deployed app on the Forgejo host, from /home/ubuntu/forgejo:

sudo docker compose exec runner-docker docker ps
sudo docker compose exec runner-docker docker exec taznado-ci-cd-example \
  node -e "fetch('http://127.0.0.1:3000/').then(r => r.text()).then(console.log)"

To stop and remove only the demo deployment:

sudo docker compose exec runner-docker docker rm -f taznado-ci-cd-example

For your own project, change IMAGE_NAME and APP_NAME, adapt the tests and Dockerfile, and configure an appropriate deployment target. An empty commit or the Actions tab's manual run starts the example pipeline again.