Harness CI integrates GitHub Actions, enabling the creation of reusable CI/CD pipelines. This integration promotes efficiency, consistency, and scalability by allowing developers to leverage pre-defined workflows, enhancing automation and reducing duplication in the software development process.
In this blog post, we'll explore how you can utilize the GitHub Actions Plugin step in your Harness Continuous Integration pipeline to create a versatile and robust continuous integration workflow. Crafting quality code within tight deadlines is a constant challenge for developers. Ensuring adherence to coding standards and best practices is crucial in this process. Harness Continuous Integration provides a solution by offering a variety of community plugins to help with code quality and beyond.
Let’s ask a question:
Why do we need reusable CI/CD pipelines?
The answer lies in efficiency and consistency. Reusable CI/CD pipelines streamline the development process by providing a standardized workflow for building, testing, and deploying applications. Rather than reinventing the wheel with each project, developers can leverage pre-defined pipelines tailored to their organization's needs. This not only saves time but also ensures consistency across projects, reducing the risk of errors and promoting collaboration among team members.
Furthermore, reusable pipelines promote scalability and maintainability. As projects evolve and new features are added, having a modular, reusable pipeline allows for easy updates and modifications without the need to overhaul the entire process. This flexibility enables teams to adapt quickly to changing requirements and iterate on their workflows efficiently.
In the next section, we'll explain the technology behind GitHub Actions and then how we can leverage GitHub Actions within the Harness CI pipeline. By utilizing these plugins, we'll demonstrate how they enable the creation of numerous pipelines while maintaining reusability. We'll explore how these tools contribute to ensuring code quality and adherence to best practices throughout the development lifecycle.
Do you know how actions run under the hood?
Actions encapsulate common tasks to reduce duplication of configuration in your pipelines. Behavior of an action is determined by the inputs passed. The code in the action runs, which can modify the pipeline environment, and potentially pass outputs to following steps in your pipeline.
Additionally, developers can use open source tools like act. to run actions locally for fast feedback and as a local task runner. act reads the actions from a directory, determines the set of actions to be run, and uses the Docker API to pull or build the necessary images defined in the action files. It then determines the execution path based on dependencies and runs containers for each action. The environment variables and filesystem are configured to match the environment provided by the platform.
This capability allows developers to test changes to their action files without needing to commit/push every time, providing fast feedback. Furthermore, developers can leverage the actions defined in their workflows to replace traditional task runners, reducing repetition and streamlining the development process.
Harness CI is based on Drone. Drone supports plugins, which can perform predefined tasks in your pipelines. Drone provides a GitHub Actions plugin, which is used by Action steps in Harness CI. The Drone GitHub Actions plugin is a wrapper around act. Harness CI also allows you to run actions from a private GitHub repository.
Let’s use hello-world-javascript-action in a Harness CI pipeline. If this is the first time you’re creating a Harness pipeline, you can follow this getting started guide.
In this Harness CI configuration, a step is defined to execute a custom action named "Hello world." The step is identified by the name "Hello_world" for reference within the Harness CI environment.
The step configuration specifies the action to be used with the uses directive. The action is sourced from an external location, and its specific implementation is not provided in this context.
Additionally, input parameters are provided to the action using the with directive. In this example, the input parameter who-to-greet is provided with the value "Captain Canary."
In the pipeline log output, you will see the message printed.
Run other actions from the vast GitHub Actions marketplace, such as linters. Here is an example of using the golangci-lint action.
Harness CI Cloud (hosted build infrastructure) offers isolated build environments on Harness-managed VMs with preconfigured tools and settings, simplifying CI pipeline setup and maintenance. With build credits for usage on preconfigured machines, starter pipelines for various languages, and rapid builds across Linux, macOS, and Windows, developers can leverage Harness Cloud to streamline software development while accessing the latest features ahead of other infrastructure options.
For other build infrastructures, you can run the Drone GitHub Actions plugin in a Plugin step.
Having explored the capabilities of Harness CI alongside examples like GitHub Actions and the super-linter plugin, it's clear that the key to efficient and effective CI/CD lies in the ability to leverage automation and maintainable workflows. By understanding how Harness CI operates under the hood and how to extend its functionality beyond its native environment, you've gained valuable insights into creating reusable pipelines that promote consistency and scalability in your development process.
If you’re using GitHub Actions, it’s time to transfer GitHub Actions into Harness CI.