This guide shows how to quickly set up CI/CD in GitLab — from creating a project and a test branch to registering a GitLab Runner and automatically deploying WordPress. This approach simplifies the development process and speeds up code updates on the server.

To create a project in GitLab:
Go to “New Project” > “Create blank Project.”

Setting up a basic project deployment (CI/CD) - Image 1

Setting up a basic project deployment (CI/CD) - Image 2

Fill in all the required information to create your new project.

Setting up a basic project deployment (CI/CD) - Image 3

Once the repository is created, you need to create a test branch to add the WordPress files.

Setting up a basic project deployment (CI/CD) - Image 4

Click the + icon and select “New Branch.”

Setting up a basic project deployment (CI/CD) - Image 5

Name the branch wp-test (as an example — you can choose any name) and click “Create branch.”

Setting up a basic project deployment (CI/CD) - Image 6

After that, switch to this branch:

Setting up a basic project deployment (CI/CD) - Image 7

Go to your test branch and add the file
.gitlab-ci.yml

Then create a Docker/ directory and add the following files inside it:
wp-traefik.prod.yml and .env

Example:
.gitlab-ci.yml

Setting up a basic project deployment (CI/CD) - Image 8

Example: wp-traefik.prod.yml

Setting up a basic project deployment (CI/CD) - Image 9

Example: .env

Setting up a basic project deployment (CI/CD) - Image 10

Now go to your production server to create a GitLab Runner, which will be used to upload your code to the target server.
On the production server, add the Docker image for the GitLab Runner:

docker run -d --name gitlab-runner --restart always \

  -v /var/run/docker.sock:/var/run/docker.sock \

  -v /gitlab-runner/config:/etc/gitlab-runner \

  gitlab/gitlab-runner:latest

Setting up a basic project deployment (CI/CD) - Image 11

Also, create a network on the production server:
docker network create web

To register the GitLab Runner, you need to obtain a token.
To do this, go to the following path:
GitLab → Settings > CI/CD > Runners > Create project runner

Setting up a basic project deployment (CI/CD) - Image 12

After that, start the registration of the GitLab Runner.

docker exec -it gitlab-runner gitlab-runner register

Enter the following information:

URL: https://gitlab.example.net
Token: <token> obtained from GitLab
Description: prod-runner
Executor: docker
Default image: php:8.2-apache

Verify the registration by running:

docker exec -it gitlab-runner gitlab-runner verify

The output should be:

Verifying runner… is valid

Once our runner has passed validation and successfully connected to GitLab, proceed to merge the test branch with main — click “Create merge request.”

Setting up a basic project deployment (CI/CD) - Image 13

After that, the tests and code deployment to the production server will start. Once the process is complete, you’ll have a fully functional WordPress website.

Setting up a basic project deployment (CI/CD) - Image 14 Setting up a basic project deployment (CI/CD) - Image 15 Setting up a basic project deployment (CI/CD) - Image 16

Conclusion

By following all the steps, you have set up a fully functional CI/CD pipeline in GitLab for your project.
The created pipeline automatically builds and deploys the application with every change in the repository, while the GitLab Runner executes tasks without manual intervention.
This approach speeds up development, reduces the risk of errors, and ensures stable code deployment to the server.
You can now expand your pipeline configuration by adding testing, security checks, or automatic Docker container updates — depending on your project’s needs.