[Avg. reading time: 15 minutes]
CICD
A CI/CD pipeline is a development practice focused on one core goal:
Ship high-quality features to production faster and more reliably.
Without CI/CD, every step in the software lifecycle is manual: building code, running tests, and deploying changes. This slows teams down and introduces human error.
What Happens Without CI/CD?
- Developers manually trigger builds
- Testing is inconsistent or delayed
- Deployments are error-prone
- Releases take longer and break more often
CI/CD fixes this by automating the entire flow.
Continuous Integration (CI)
- Automatically builds and tests code whenever changes are pushed to a shared repository
- Detects issues early before they reach production
- Ensures new code doesn’t break existing functionality
Keep the codebase stable at all times
Continuous Delivery (CD)
- Automatically deploys validated code to staging or testing environments
- Production deployment is still a manual decision
Always be ready to release.
Continuous Deployment
- Extends Continuous Delivery
- Every successful change is automatically deployed to production
Remove manual steps and release continuously.
There are many CI/CD tools available. They differ mainly in hosting model and integration ecosystem.
Categories of CI/CD Tools
Self-Hosted / On-Prem
-
Jenkins
-
CircleCI (can be self-hosted, though mostly SaaS now)
-
You need full control
-
Strict security/compliance
-
Custom infrastructure
SaaS / Web-Based
-
GitHub Actions
-
GitLab CI/CD
-
You want quick setup
-
Tight integration with source control
Cloud-Native Tools
-
AWS CodeBuild / CodePipeline
-
Azure DevOps
-
Google Cloud Build
-
You’re already in that cloud
-
Need deep integration with cloud services
GitHub Actions
One of the most widely used CI/CD tools today.
- Native integration with GitHub
- Free tier available
- Huge marketplace of reusable actions
Core Five Concepts
Workflows
- Define the automation pipeline
- Stored as YAML files in .github/workflows/
- Think: entire pipeline definition
Jobs
- A workflow is made up of one or more jobs
- Jobs run independently (can be parallel)
- Each job contains multiple steps
Steps
- Individual tasks inside a job
- Example: install dependencies, run tests
Events (Triggers)
Trigger the execution of the job.
- on push / pull
- on schedule
- on workflow_dispatch (Manual Trigger)
Actions
Reusable building blocks.
Example:
- checkout repo
- setup Python
- deploy apps
https://github.com/features/actions
Runners
Remote computer that GitHub Actions uses to execute the jobs.
Github-Hosted Runners
- ubuntu-latest
- windows-latest
- macos-latest
Self-Hosted Runners
- Specific OS that Github does not offer.
- Connection to a private network/environment.
- To save costs for projects with high usage. (Enterprise plans are expensive)
YAML (Yet Another Markup Language)
- Human-readable
- Key-value structure
- Indentation matters
https://learnxinyminutes.com/docs/yaml/
DEMO
Multiple Runners Demo
https://github.com/gchandra10/github-actions-multiple-runners-demo
Rust DEMO
git clone https://github.com/gchandra10/rust-ci-demo
Sample
name: Rust
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build_step:
runs-on: ubuntu-latest
steps:
- name: Discord - Process started
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: ' :information_source: The Calculator App {{ EVENT_PAYLOAD.repository.full_name }} workflow (${{ github.run_id }}) was triggered by ${{ github.actor }}'
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
# - name: Format the Code
# uses: actions-rs/cargo@v1
# with:
# command: fmt
- name: Send Discord Failure Notification
# https://github.com/marketplace/actions/actions-for-discord
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '@here :x: The Calculator App integration {{ EVENT_PAYLOAD.repository.full_name }} test failed. Check the Run id ${{ github.run_id }} on Github for details.'
- name: Send Discord Success Notification
# https://github.com/marketplace/actions/actions-for-discord
if: success()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: ' :white_check_mark: The Calculator App {{ EVENT_PAYLOAD.repository.full_name }} - ${{ github.run_id }} successfully integrated and tested.'
# - name: Generate Documentation
# uses: actions-rs/cargo@v1
# with:
# command: doc
## Not that popular these days.
# - name: Send Email Notification on Failure
# if: failure()
# uses: dawidd6/action-send-mail@v2
# with:
# server_address: ${{ secrets.EMAIL_SERVER }}
# server_port: ${{ secrets.EMAIL_PORT }}
# username: ${{ secrets.EMAIL_USERNAME }}
# password: ${{ secrets.EMAIL_PASSWORD }}
# subject: CI Failure in ${{ github.repository }}
# to: chandr34@rowan.edu
# from: chandr34@rowan.edu
# body: The Rust CI test failed. Check the details on GitHub.
1: www.freecodecamp.org/