30 Abr 2024 CI/CD with GitHub Actions
Software development is constantly evolving, and process automation is playing a crucial role. Here at ClearPeaks we fully recognise the importance of seamless code integration and the efficient deployment of solutions to the end user. Lots of solutions have been developed to simplify this workflow, ensuring that we stay at the forefront of technology and service excellence.
What is CI/CD?
It stands for Continuous Integration and Continuous Delivery, but what exactly does this mean?
CI/CD represents a set of practices and tools that have revolutionised software development, allowing developers to automate various aspects of the software delivery process, from code integration to the final deployment. With CI/CD, development teams can cut down on manual tasks, collaborate better, and accelerate the delivery of new features and updates to their end users.
Let’s look at the two parts!
CI (Continuous Integration)
CI is the practice of integrating code changes in a repository or version control system. It’s typically used by multiple developers, each of whom merges changes into a common codebase as part of their daily workflow. The process ensures that newly merged code does not introduce errors, or conflict with existing code, and stability in the codebase is maintained by triggering automated build and testing processes.
CD (Continuous Delivery)
CD, in conjunction with CI, automates the provision of infrastructure and the release of applications after they are built and tested. From infrastructure provision to deployment in test or production environments, this process covers different stages.
In the release phase, the software is configured for deployment to production at any time; deployments, both manual and automated, can be triggered as required.
Continuous deployment enables DevOps teams to release applications automatically, meeting quality criteria and speeding up the delivery of new features to users.
Benefits and Drawbacks of CI/CD
- Faster development: CI/CD pipelines automate the process of building and testing code whenever changes are made in the repository.
- Reduce errors: CI/CD supports frequent testing, making it easier to detect bugs or errors.
- Consistency: CI/CD pipelines define standardised processes for building, testing, and deploying code, and this consistency helps to maintain a uniform quality across development, staging, and production environments.
- Increased collaboration: CI/CD promotes the concept of the cross-functional team, where developers, testers, and operations personnel work together, encouraging a more holistic approach to software development.
However, there are also some drawbacks:
- Complexity and the learning curve: Implementing CI/CD pipelines can be complex, especially for teams new to the concept. Learning the tools and best practices can take both time and effort.
- Initial setup: Setting up a robust CI/CD infrastructure can be time-consuming and resource-intensive, and may also mean changes to existing workflows and tools.
- Infrastructure cost: Maintaining CI/CD infrastructure, especially in the cloud, can lead to additional costs, and the use of CI/CD services may also incur fees.
There are multiple CI/CD tools available to developers. In this blog post we‘ll be diving into GitHub Actions. But first, take a look at First step towards DataOps – CI/CD on Azure Data Factory where we get into the details of CI/CD with Azure.
GitHub Actions
GitHub Actions is an automation and workflow orchestration tool provided by GitHub, enabling developers to automate various aspects of their software workflows directly within their GitHub repositories. This tool is specifically designed to facilitate processes such as building, testing, and deploying the codebase, streamlining these operations seamlessly.
Why use GitHub Actions?
- Integration with GitHub: GitHub Actions allows you to define CI/CD pipelines directly in your GitHub repositories, making it easy to access and manage your workflows within the same environment as your code.
- Flexibility: GitHub Actions offers a high degree of flexibility when it comes to defining your automation workflows: you can create custom workflows to automate a wide range of tasks, from building and testing code to deploying applications or even automating documentation generation.
- Diverse event triggers: These triggers allow you to automate processes based on real-time changes and activities within your project, making it a powerful tool for continuous integration and deployment.
- Third-party integration: GitHub Actions supports third-party integrations with numerous services and tools, meaning you can easily integrate and automate processes involving external services, cloud platforms, databases, and other tools that your project relies on.
- Scheduled workflows: GitHub Actions enables you to schedule workflows to run at specific times or intervals, especially useful for tasks like regular data backups, database maintenance, or generating reports on a daily, weekly, or monthly basis.
Creating a GitHub Actions Workflow
Firstly, we create a new repository where we’ll store our Angular application. Once the Angular project has been developed and connected to a GitHub repository, we’ll need to create a new folder named github and a directory within it called workflows. Inside this directory we then create a YAML file where we’ll define the logic of this workflow:
Now we need to modify the configuration so that specific commands are executed to test and build our project. T do so, we must add the following commands to our package.json file:
Once the configuration is complete, the final step is to create the workflow itself. We’ll return to the previously created ci_cd_pipeline.yml file and add this code:
Now our pipeline is configured to test and build our Angular project whenever there is a push or a pull request to the main branch. In the repository, navigate to the Actions section. Here, after creating a pull request or directly pushing to the main branch, you can observe the workflow process that we set up in the previous step:
Conclusion
In conclusion, CI/CD is more than just a development methodology: it’s a mindset that encourages innovation, agility, and reliability, ensuring that software development keeps pace with the demands of the digital era, where change is constant, and user expectations are higher than ever.
The importance of CI/CD cannot be overstated. Its adoption is not a matter of if but when, and those who integrate it into their software development processes will find themselves better equipped to thrive in the competitive landscape of today’s digital world.
Here at ClearPeaks we always strive for success and that’s why we place enormous importance on the different aspects of software development, to deliver the best product to our customers, with faster, more reliable, and more responsive applications.
Are you ready to streamline your development process with powerful CI/CD solutions? Our team of experts is here to guide you through every step, from initial setup to full deployment, so reach out today for a consultation!