Skip to content
Lab 3 of 3

CI/CD with Git Hooks: Test, Build, Deploy

Build a working CI/CD pipeline with nothing but git and a hook: push to a bare repo, run the test suite automatically, watch a red build block the deploy, fix the bug, and ship two releases to a live web server.
  • Advanced
  • 45 min
  • CI/CD
  • Git
  • DevOps
  • Automation

Overview

Jenkins, GitHub Actions and GitLab CI are, at heart, one idea: when code arrives, run something. In this lab you build a working CI/CD pipeline from the primitive that idea is made of — a git hook — with no CI server at all.

You'll put an app under version control, push to a central bare repository, and install a post-receive hook that runs the test suite on every push. Then you'll watch the pipeline do its most important job: go red and refuse to deploy buggy code. You'll fix the bug, go green, watch it deploy automatically, and ship a second release — proving the pipeline works when it matters most, on the next change.

What you will learn

  • Initialize a repository and make your first commit
  • Create a bare repository and push to it — the CI-server model
  • Install a post-receive hook that runs tests automatically on every push
  • Experience a red build blocking a deploy, then fix the code to go green
  • Ship two releases through a fully automatic test → build → deploy pipeline

Before you start

  • Earlier DevOps labs first, or comfort with the shell and sudo
  • You've used git add / commit / push before
  • You can read a few lines of Python and Bash

Tasks

  1. 01Put the app under version control
  2. 02Create the central bare repo and push
  3. 03Install the CI hook — and watch it go red
  4. 04Fix the bug, go green, deploy
  5. 05Ship release 2.0