DevOps Day 20 – GitHub Actions Workflow with YAML (Modern CI/CD)
DevOps Day 20 – GitHub Actions Workflow with YAML (Modern CI/CD) 🚀
Welcome to Day 20 of the DevOps Series.
So far, we’ve explored CI/CD concepts and Jenkins pipelines.
Today, we move into modern CI/CD with GitHub Actions — a powerful, cloud-native automation tool built directly into GitHub.
GitHub Actions allows you to build, test, and deploy applications using YAML-based workflows, without managing any servers.
🔍 What is GitHub Actions?
GitHub Actions is a CI/CD platform that automates workflows based on events in a GitHub repository.
These events can include:
-
Code push
-
Pull request
-
Release creation
-
Manual trigger
Everything is defined using YAML workflows, stored directly in your repo.
📁 Location:
⚙️ Core Components of GitHub Actions
🔹 Workflow
A workflow is an automated process triggered by an event.
Defined as a .yml file inside .github/workflows/.
🔹 Events
Events decide when the workflow runs.
Common events:
-
push -
pull_request -
workflow_dispatch(manual trigger)
🔹 Jobs
A workflow contains one or more jobs.
Each job:
-
Runs on a virtual machine (runner)
-
Executes steps sequentially
🔹 Runners
Runners are the machines that execute workflows.
Examples:
-
ubuntu-latest -
windows-latest -
macos-latest
GitHub automatically spins them up and shuts them down — zero infrastructure management.
🔹 Steps
Steps are individual tasks inside a job.
Examples:
-
Checkout code
-
Install dependencies
-
Run tests
-
Build application
-
Deploy
📄 Basic GitHub Actions Workflow Example
This workflow:
-
Triggers on every push to
main -
Runs on Ubuntu
-
Builds and tests the application
🚀 CI/CD Flow with GitHub Actions
1️⃣ Developer pushes code to GitHub
2️⃣ GitHub event triggers workflow
3️⃣ Runner spins up automatically
4️⃣ Build, test, and deploy steps execute
5️⃣ Runner shuts down after completion
💡 No idle servers. No Jenkins maintenance.
🔁 GitHub Actions vs Jenkins
| Feature | GitHub Actions | Jenkins |
|---|---|---|
| Setup | Zero setup | Manual installation |
| Infrastructure | Managed by GitHub | Self-managed |
| Scalability | Auto-scale | Manual scaling |
| Cost | Pay-per-use | Always-on servers |
| Configuration | YAML | Groovy + UI |
🌍 Real-World Use Cases
✅ CI Pipeline
-
Run unit tests
-
Static code analysis
-
Generate reports
✅ CD Pipeline
-
Deploy to cloud (AWS, Azure, GCP)
-
Deploy to Kubernetes
-
Publish Docker images
✅ Open Source Projects
-
PR validation
-
Security scans
-
Automated releases
✅ Microservices
-
Independent workflows per service
-
Event-driven pipelines
-
Faster feedback loops
🔐 Secrets & Environment Variables
Sensitive data like tokens and passwords are stored securely using GitHub Secrets.
Example:
Secrets are:
-
Encrypted
-
Masked in logs
-
Scoped per repository or environment
🧠 DevOps Best Practice
✔ Keep workflows small and modular
✔ Use reusable workflows
✔ Fail fast using test stages
✔ Use caching for faster builds
✔ Secure secrets properly
✅ Summary
In Day 20, we learned:
-
What GitHub Actions is
-
Workflow structure using YAML
-
Jobs, runners, and steps
-
CI/CD automation with zero infrastructure
-
Why GitHub Actions is ideal for modern DevOps
GitHub Actions represents the future of CI/CD — fast, scalable, and deeply integrated with source control.
Comments
Post a Comment