π― Goal
By the end of this lab you should understand this workflow:
Create Project
β
Git
β
Feature Branch
β
Change Code
β
Commit
β
Push
β
GitHub
β
Pull Request
β
Merge
β
git pull
β
GitHub Actions
β
CI
Important: Do the lab yourself. Don't just copy commands. After every important command, ask yourself: What did this command just do?
PART 1 β Create Your Project
Open Terminal.
Create a new project:
cd ~
mkdir weekend-devops-lab
cd weekend-devops-lab
Check your location:
pwd
Create:
touch index.html
Open it:
nano index.html
Add:
<!DOCTYPE html>
<html>
<head>
<title>My DevOps Project</title>
</head>
<body>
<h1>Welcome to My DevOps Project</h1>
<p>Created by YOUR NAME</p>
<h2>Skills</h2>
<ul>
<li>Linux</li>
<li>Git</li>
<li>GitHub</li>
<li>AWS</li>
</ul>
</body>
</html>
Save.
Check:
ls
PART 2 β Initialize Git
Run:
git init
Then:
git status
Question
Why does Git show:
untracked
Answer this yourself before continuing.
Now:
git add index.html
Check again:
git status
Create your first commit:
git commit -m "Create initial website"
Check history:
git log --oneline
PART 3 β Create GitHub Repository
Go to GitHub.
Create a repository named:
weekend-devops-lab
For this exercise, create it empty.
Don't add README, .gitignore, or License when creating it.
Connect your local repository to GitHub using the repository URL GitHub gives you:
git remote add origin YOUR-GITHUB-REPOSITORY-URL
Check:
git remote -v
Rename your main branch if needed:
git branch -M main
Push:
git push -u origin main
Now refresh GitHub.
You should see:
index.html
PART 4 β Create a Feature Branch
Do NOT change main directly.
First:
git branch
Create:
git switch -c feature-about
Check:
git branch
You should see:
* feature-about
main
Question
What does * mean?
PART 5 β Change Your Website
Open:
nano index.html
Add:
<h2>About Me</h2>
<p>I am learning DevOps Engineering.</p>
<p>This website is managed using Git and GitHub.</p>
Save.
Now do not immediately add it.
First:
git status
Then:
git diff
Look at what changed.
Then:
git add index.html
Check:
git status
Commit:
git commit -m "Add About section"
Check:
git log --oneline
PART 6 β Push Your Feature Branch
Push:
git push -u origin feature-about
Open GitHub.
You should now have:
main
feature-about
Question
Is the About section already inside main?
Think before continuing.
PART 7 β Pull Request
On GitHub create a:
Pull Request
Use:
base: main
compare: feature-about
Before merging, look at:
Files changed
Read your own changes.
Then merge the Pull Request.
Now:
feature-about
β
Pull Request
β
Review
β
Merge
β
main
PART 8 β Very Important Test
Go back to Terminal.
Switch to:
git switch main
Now look at your file:
cat index.html
STOP HERE.
Ask yourself:
I merged the PR on GitHub. Why might my local
mainstill not have the newest change?
Because:
LOCAL != REMOTE
Now run:
git pull origin main
Then:
cat index.html
Check history:
git log --oneline
Your local main should now contain the merged change.
PART 9 β Push / Pull / Clone Challenge
Without looking at notes, answer:
I changed code locally and want to send it to GitHub.
Command = ?
Someone changed GitHub and I already have the repository.
Command = ?
I am a new employee and don't have the repository at all.
Command = ?
Answers:
git push
git pull
git clone
PART 10 β Create Your First CI
Now add GitHub Actions.
Make sure you're on main:
git switch main
Update it:
git pull origin main
Create the workflow directory:
mkdir -p .github/workflows
Create:
nano .github/workflows/ci.yml
Add:
name: Weekend CI
on:
push:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Say Hello
run: echo "Hello from my CI pipeline"
- name: Check Runner
run: |
whoami
pwd
- name: Finish
run: echo "CI PASSED"
Save.
PART 11 β Before You Push
Run:
git status
Ask:
What new file does Git see?
Then:
git add .github/workflows/ci.yml
Commit:
git commit -m "Add first CI workflow"
Push:
git push origin main
PART 12 β Watch CI
Go to:
GitHub β Repository β Actions
Find:
Weekend CI
Open it.
Find the job:
test
Open the steps.
You should see:
Say Hello
β
Check Runner
β
Finish
β
Congratulations β you triggered a CI workflow.
But don't stop at the green checkmark.
You must understand what happened:
git push
β
GitHub received new commit
β
push triggered workflow
β
GitHub created a Runner
β
Runner executed Job
β
Job executed Steps
β
Commands executed
β
CI PASSED
PART 13 β Explain Your YAML
Be prepared to explain these on Monday:
name:
What does it mean?
on:
push:
What does it mean?
jobs:
What is a Job?
runs-on: ubuntu-latest
What is a Runner?
steps:
What are Steps?
run:
What does run do?
PART 14 β Troubleshooting Challenge
I don't want them to only follow a happy path.
Change:
- name: Finish
run: echo "CI PASSED"
temporarily to:
- name: Test Failure
run: exit 1
Then:
git add .
git commit -m "Test CI failure"
git push
Go to GitHub Actions.
Your pipeline should fail.
Find:
β
Open the failed job.
Find the failed step.
Then fix the workflow by changing it back to:
- name: Finish
run: echo "CI PASSED"
Commit and push again:
git add .
git commit -m "Fix CI workflow"
git push
Your goal:
β FAILED
β
Investigate
β
Fix
β
Commit
β
Push
β
β PASSED
This is much closer to what DevOps engineers actually do.
PART 15 β Bonus: Deploy It to EC2
Students who finish early should continue.
On Ubuntu EC2:
sudo apt update
sudo apt install git nginx -y
Then:
git clone YOUR-GITHUB-REPOSITORY-URL
Enter repository:
cd weekend-devops-lab
Deploy:
sudo cp index.html /var/www/html/index.html
Check:
sudo systemctl status nginx
Test locally:
curl localhost
Then open:
http://YOUR-EC2-PUBLIC-IP
Now your complete architecture is:
Developer
β
Git
β
GitHub
β
CI
β
Repository
β
EC2
β
Nginx
β
Port 80
β
Browser
What Students Must Submit
Each student should send you one GitHub repository link plus screenshots showing:
- Repository with
index.html - Feature branch
- Pull Request
- Merged PR
.github/workflows/ci.yml- Successful GitHub Actions run β
- Failed CI run β and the later fixed successful run β
- Bonus: website running from EC2/Nginx
And prepare a 2β3 minute presentation for Monday explaining:
What is Git?
What is GitHub?
What is a Branch?
What is a Pull Request?
What does git push do?
What does git pull do?
What is CI?
What triggered your workflow?
What is a Runner?
What is a Job?
What is a Step?
Why did your CI fail?
How did you fix it?
Top comments (0)