Part 8 - Setting Up Continuous Integration (CI)
This is the final post in the series of how to host your own git server on a Raspberry Pi
Throughout this series, you have successfully set up a Raspberry Pi, installed Postfix, GitLab, Nginx, and configured GitLab Runners. Additionally in the previous post, you have added SSL/HTTPs support to these services. Congratulations, these were no easy tasks!
You are nearly done — In this final post, we will go over creating a GitLab project and setting up continuous integration. We will also look into writing a CI file that will ingest commits to your project and deploy them to production.

1. Create GitLab Project
From the main screen of the GitLab, create a new project with Initialize repository with a README option selected. This will allow you to clone the project from your Raspberry Pi to your computer immediately.
Run following command from your computer to clone the project via HTTPs:
git clone https://git.<HOSTNAME>.<DOMAIN>/<USER>/<PROJECT-SLUG>.git
Git will ask the user name and password for your GitLab account, then proceed to clone your project. You will see the downloaded project to contain a blank README.md file.
2. Add Project Files
In Part 6 of this series, we have created an index.html file to serve as the home page for our Raspberry Pi. We will use our git project to host the source files for this page.
As a reminder, the source files for this page is stored at /var/www/home/
and the Nginx configuration file is in /etc/nginx/sites-available/home
on the Raspberry Pi. The page is accessible via https://<HOSTNAME>.<DOMAIN>
Create a new index.html for your home page as follows:
<html>
<head>
<title>Home</title>
</head>
<body>
Home Page
</body>
</html>
Place this file in your git project repository.
3. Create CI Configuration
GitLab uses yaml language to define CI scripts. You can create a file named .gitlab-ci.yml (with a leading dot) and add it your git project repository. The content of our CI script will look like the following:
stages:
- build
- test
- deploy
build:
stage: build
script:
- echo "*** Build Phase ***"
- echo "There are no build steps."
test:
stage: test
dependencies:
- build
script:
- echo "*** Test Phase ***"
- echo "There are no test steps."
deploy:
stage: deploy
dependencies:
- test
script:
- echo "*** Deploy Phase ***"
- echo "Current path:"
- pwd
- echo "Removing dot files..."
- find . -name ".*" -type f -delete
- echo "Removing git folder..."
- rm -rf "./.git"
- echo "Source directory:"
- ls -a
- echo "Clearing target..."
- find /var/www/home/ -mindepth 1 -exec sudo rm -rf {} +
- echo "Deploying files..."
- sudo cp -r . "/var/www/home"
- echo "Target directory:"
- ls -a /var/www/home/
- echo "Deploy success."
The script copies the project source files into /var/www/home/
, replacing the old page contents. This will update the home page, essentially deploying your changes into production.
3. Commit Your Changes
Use following commands to commit your project files to GitLab:
git add -A
git commit -m “First Commit”
git push origin main
GitLab will detect that your project contains a .gitlab-ci.yml and start the continuous integration pipeline:

This pipeline will execute each time you push a change to your project, deploying the new version of the home page.
When you check the home page for your Raspberry Pi, following https://<HOSTNAME>.<DOMAIN>
, you will see the contents of the home page is updated!
🎉🎉🎊🎊🎊
Congratulations — YOU ARE DONE!