0
0
Gitdevops~30 mins

Why Git integrates with CI/CD - See It in Action

Choose your learning style9 modes available
Why Git Integrates with CI/CD
📖 Scenario: You work in a team that builds software. You use Git to save your code changes. Your team wants to make sure the code is always tested and ready to use. This is done using CI/CD tools that run tests and deploy code automatically.
🎯 Goal: Learn how Git connects with CI/CD by creating a simple Git repository, adding a configuration file to trigger CI/CD, and seeing the result of the integration.
📋 What You'll Learn
Create a Git repository with a README file
Add a CI/CD configuration file named .github/workflows/ci.yml
Write a simple CI job that runs on push
Show the Git commands to push changes and trigger CI/CD
💡 Why This Matters
🌍 Real World
Teams use Git with CI/CD to automatically test and deploy code changes, saving time and reducing errors.
💼 Career
Understanding Git and CI/CD integration is essential for software developers, DevOps engineers, and anyone working in modern software teams.
Progress0 / 4 steps
1
Create a Git repository with a README file
Initialize a Git repository in the current folder using git init. Then create a file named README.md with the exact content # My Project. Finally, add the file to Git using git add README.md.
Git
Need a hint?

Use git init to start a new repository. Use echo to create the README file. Use git add to stage the file.

2
Add a CI/CD configuration file
Create a folder named .github/workflows. Inside it, create a file named ci.yml with the following content exactly:
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo "Running tests..."
Git
Need a hint?

Create the folders with mkdir -p. Use echo with escaped quotes to write the YAML file.

3
Commit and push changes to trigger CI/CD
Commit your changes with the message "Add CI workflow" using git commit -m "Add CI workflow". Then push to the remote repository using git push origin main. Assume the remote is already set.
Git
Need a hint?

Use git commit -m to save changes with a message. Use git push origin main to send changes to the remote.

4
Show the output of the CI job running
Print the exact text Running tests... to simulate the CI job output.
Git
Need a hint?

Use echo "Running tests..." to show the CI job output.