Working with GitLab

Git workflow & deployment

From feature branch to production deployment: commit, push, merge, and roll out.

On this page

The platform takes deployment completely off your plate. You work with Git as usual – everything that happens after the push is already set up.

The branch model

Locally you only need two kinds of branches:

  • main – the main branch. Whatever lands here is rolled out to the dev server automatically.
  • Feature branches – one branch per change, merged back into main via merge request.
flowchart LR
  feature["Feature branch"] -->|"Merge request"| mainBranch["main"]
  mainBranch -->|"Pipeline builds Docker image"| image["Docker image"]
  image -->|"automatic"| devServer["Dev server"]
  image -->|"manual click:<br/>publish-docker-prod"| prodServer["Prod server"]

Step by step: developing a change

  1. Create a feature branch:
git checkout main
git pull
git checkout -b feature/my-feature
  1. Make your changes, commit, and push:
git add .
git commit -m "feat: my feature"
git push -u origin feature/my-feature
  1. Create a merge request into main in GitLab. The pipeline builds and checks your branch automatically.
  2. Merge the merge request – done. The platform handles the rest.
Tip
Small, focused merge requests are easier to review and reach the server faster than one big branch that lives for weeks.

What happens after the merge (dev)

As soon as your code is in main, the repository’s pipeline runs automatically:

  1. update-version – computes the new version number.
  2. build-docker – builds the Docker image and pushes it to the registry.
  3. publish-docker-dev – writes the new image tag into configurations/dev/versions.yaml of your gitops-configuration repository.
  4. The GitOps repository then deploys the new version to the dev server via Ansible.

No action needed – a few minutes after the merge, your change is live on dev. You can follow the progress in GitLab under CI/CD → Pipelines (in the code repository and in the gitops-configuration repository).

Rolling out to production

The prod deployment is intentionally a manual step – the same build that already runs on dev is released with one click:

  1. Open your code repository in GitLab and go to CI/CD → Pipelines.
  2. Open the pipeline of the main state you want to release.
  3. Start the publish-docker-prod job via the play button.

The job writes the image tag into configurations/prod/versions.yaml, and the GitOps repository rolls the version out to the prod server.

Warning
publish-docker-prod releases exactly the state of that pipeline. Before clicking, verify that the change works as expected on dev.

Feature branches and previews

The pipeline also builds a Docker image on feature branches (publish-docker-dynamic). This makes it possible to test a branch in its own environment before merging.

See also