Khachatryan-dev

How CI/CD Works

The Importance and Secrets of CI/CD

Aram
Khachatryan

The Importance and Secrets of CI/CD





Introduction




As time and information rapidly evolve, many new technologies emerge that automate the human factor. Many developers think that CI/CD is just a toolset for DevOps engineers, but the pace of development forces developers to learn and apply new technologies. To enhance your professional level, I recommend learning this technology as well. It will help you stay competitive in the market.


About CI/CD




Modern software development requires fast development and high-quality assurance. To achieve this, the Continuous Integration and Continuous Deployment (CI/CD) methodology is used.


CI/CD automates the processes of code integration, testing, and deployment, which reduces the number of manual actions, accelerates the release of new features, and improves software reliability.


  • Continuous Integration (CI) – ensures that every change in the software code is checked and merged with the main codebase, reducing the likelihood of integration issues.
  • Continuous Deployment (CD) – automates the process of checking and deploying code to the production environment, ensuring fast and safe releases of new changes.

Implementing CI/CD is important for both small and large software projects, as it improves the efficiency of the development process and reduces the likelihood of errors in the production environment.


🚀 How to Start and Implement CI/CD




Implementing CI/CD requires a phased approach, including tool selection, environment setup, planning, and automation.




1. Choose CI/CD Tools


Depending on the technology stack, various CI/CD tools can be selected, such as:

  • GitHub Actions – suitable for integration with GitHub.
  • GitLab CI/CD – integrated into the GitLab platform and allows automating all development stages.
  • Jenkins – a powerful and flexible tool that works in any environment.
  • CircleCI, Travis CI, Bitbucket Pipelines – other popular cloud CI/CD solutions.

2. Set Up Continuous Integration (CI)


The main goal of CI is to automatically check and test every change in the code.

✅ Steps


  • Create a Git repository, for example, on GitHub or GitLab.
  • Create a CI plan, including the following steps:
    • Installing dependencies
    • Linting and static analysis of the code
    • Automatically running tests
  • Create a CI configuration file (e.g., .github/workflows/ci.yml, .gitlab-ci.yml, or Jenkinsfile).
  • CircleCI, Travis CI, Bitbucket Pipelines – other popular solutions that offer cloud CI/CD.
  • Test and fix any potential errors.

3. Set Up Continuous Deployment (CD)


CD ensures that code passing tests is automatically deployed to the server or cloud environment.

✅ Steps


  • Select a deployment environment:
    • VPS (e.g., DigitalOcean, AWS EC2, Linode)
    • Containers (Docker, Kubernetes)
    • Cloud solutions (Vercel, Netlify, Firebase Hosting, AWS, Azure, GCP)
  • Create the deployment process:
    • Create a build
    • Package or containerize
    • Deploy in production or staging environments
  • Test the deployed application.

At the end of the article, I will share my git repository, where you can find several examples.

Additionally, I will explain the YAML format and its usage guidelines.

What is YAML?




YAML (Yet Another Markup Language or YAML Ain't Markup Language) is a readable and lightweight data serialization language widely used for configuration files. YAML is particularly suitable for CI/CD planning (GitHub Actions, GitLab CI/CD, Jenkins), Docker Compose, Kubernetes, Ansible, and other DevOps tools.

Basic YAML Rules




✅ Simple and hierarchical structure

YAML uses unique indentation to define hierarchy (instead of braces or markup tags like in JSON or XML).

 app:
name: "My Application"
version: 1.0
environment: "production"

   



🔹 Indentation is required, use 2 or 4 spaces (not tabs).

✅ Key-Value Pairs



server: "localhost"
port: 8080
debug: true

🔹 Text values can be quoted as "string" or without quotes.

✅ Lists (Arrays)




In YAML, lists (arrays) are represented with the "-" symbol.


freamworks:
  - React
  - Vue
  - Angula



🔹 They can also be in key-value format.


 database:
mysql:
version: "8.0"
port: 3306
psotgresql:
version: "15"
port: 5432



✅ Multiline Texts




If you need to write multiline values, use the | (literal block) or > (folded block) symbol.

 message: |
This is a multi-line
    text that is preserved 
    in the same form.


 message: >
This is multi-line text,
but each new line is
converted to a space.

✅ Numbers and Boolean Values




If you need to write multiline values, use the | (literal block) or > (folded block) symbol.

yaml_example

🔹 Boolean values can be true/false, on/off, yes/no.

🔹 Numbers can be integers (integer) or floating-point (float).

Reusing Data in YAML (Anchors & Aliases)




YAML allows data reuse using &anchor and *alias symbols.


 default_config: &config
retries: 3
timeout: 10
log_level: "debug"

service_1:
<<: &config
name: "API Service"
service_1:
<<: &config
name: "Worker Service"



🔹 ❬❬ *config means that service_1 and service_2 inherit the default_config values.

YAML Error Prevention Tips





Typical errors:


❌ Using tabs

✅ Use 2 or 4 spaces instead of tabs.

You can find more detailed information in my git repository.

Buy me a coffee
  • 0
  • 16

Discover More Content

Comments
No data
No comments yet. Be the first to comment!
Leave a Comment
You must be logged in to leave a comment.Login