GitHub Actions CI CD
GitHub Actions CI CD
GITHUB
ACTIONS
ROHAN THAPA
[email protected]
Introduction to CI/CD
Continuous Integration (CI):
Goal: Automatically integrate and test
code changes frequently.
Purpose: Developers commit code
frequently to the shared repository.
Automated tests are run to ensure new
changes don't break existing functionality.
Events:
Events are activities that trigger the
workflow. Example events include push,
pull_request, release, or scheduled cron
jobs.
Key Concepts in GitHub Actions
Jobs:
A job is a set of steps that run on the same
runner.
Jobs can run sequentially or in parallel.
Each job runs on its own virtual machine
(runner).
Steps:
Steps are individual tasks that make up a
job. These steps can run commands,
scripts, or actions.
You can either write your own commands
or use existing pre-defined actions from
the GitHub Actions marketplace.
Key Concepts in GitHub Actions
Runners:
Runners are servers that run the jobs.
GitHub provides free hosted runners, or
you can use self-hosted runners.
Hosted runners come with predefined
environments (e.g., Linux, Windows,
macOS).
Anatomy of a GitHub Actions Workflow
1. Build:
The project is built using Maven or Gradle.
4. Deploy to Staging/Production:
Once tests pass, the application can be
deployed to a staging or production
environment.
Advanced Features of GitHub Actions
1. Parallel Jobs:
You can run different jobs in parallel to
speed up the workflow. For instance, you
can run tests in parallel across different
environments.
Advanced Features of GitHub Actions
2. Caching Dependencies:
Caching Maven or Gradle dependencies to
reduce build times.
Advanced Features of GitHub Actions
3. Notifications:
You can send notifications to team
members via Slack, email, or other tools if
a build or deployment succeeds or fails.
Continuous Deployment (CD) with GitHub
Actions
Once the CI pipeline passes, we can set up
Continuous Deployment to automatically
deploy the application. You can deploy to
services like AWS, Heroku, or DigitalOcean.
Docker file
Complete Example with CI/CD
Continuous
Integration
Complete Example with CI/CD
In Action
Complete Example with CI/CD
Deployment
Complete Example with CI/CD
In Action
Complete Example with CI/CD
Uploaded to Dockerhub
Enable Caching:
Leverage caching to speed up build times
for dependencies and artifacts.
Best Practices for CI/CD with
Github Action
Monitor & Debug:
Use GitHub’s detailed logs to identify
bottlenecks, issues, and failed steps.
Parallelize Jobs:
Run independent jobs in parallel to speed
up the overall workflow.
Advantages of GitHub Actions for
CI/CD
Deep GitHub Integration: Native support
and tight integration with GitHub
repositories.