CI/CD is a safety net for developers working in teams. It helps reduce human error by automating two key development workflows - testing and deployment.
Learning CI/CD will allow you to:
A well engineered CI/CD system offers repeatable, low maintenance deployments. It’s a crucial part of working with others - with CI you know that both your and your colleagues code has passed tests, and that deployments are done consistently across the entire team.
Continuous Integration (CI) is a software engineering technique where changes to a codebase are tested automatically before merging code and deploying to environments like dev or prod.
Testing allows teams to detect and fix problems before they are merged into branches that deploy infrastructure to the cloud.
CI is based around testing Git branches, commonly on pull requests, run before code is merged from one branch to another. These tests are often run when a pull request is open. Each commit to the branch will kick off testing of the updated code.
It’s common to run tests again after a branch has been merged, to ensure that the codebase is still working as expected.
GitHub Actions integrates directly with GitHub.
Github Actions is configured with yaml
files into the .github/workflows
folder of a GitHub repository.
The file .github/workflows/test.yaml
below is a CI workflow that runs on every pull request to the main
branch:
In Github Actions, pipelines will automatically be setup when the YAML file is put into the .github/workflows
folder in a GitHub repository.
Azure DevOps also uses pipelines defined in yaml
to define CI workflows.
Below is an example of a CI pipeline that runs on every pull request to the main
branch:
In Azure Devops, pipelines will not automatically run when the YAML file is created. You need to setup the pipeline through the Azure Devops web interface after adding the YAML file to your Azure Devops respository.
Continuous Deployment (CD) is a software engineering technique where changes to a codebase are deployed automatically.
Automated deployments allows teams to deploy infrastructure to the cloud automatically, without any manual work. Manual deployments come with the non-zero risk of human error, and cost of developer time.
CD is based around deploying Git branches, commonly after code is merged or pushed from one branch to another. CD should only occur after CI tests have passed.
.github/workflows/deploy.yaml
is a CD workflow that runs on every push to the main
branch:
The environment variables AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
are set from secrets in the GitHub repository. These secrets are usually added manually via the GitHub web interface.
Below is an example of a CD pipeline that runs on every push to the main
branch:
The environment variables CLIENT_ID
, CLIENT_SECRET
and TENANT_ID
are set from variables in the Azure Devops pipeline. These secrets are usually added manually via the Azure Devops web interface.