Declaring Configuration for Self-Hosted Build Agents with Continuous Integration (CI) on GH Actions
In Android app development, we leverage GitHub Actions running our CI pipelines across self-hosted agents. After upgrading several libraries and requiring an alternative JDK version, manual configuration of each agent’s environment became impractical due to the cumbersome setup process. To address this challenge efficiently without Docker overhead or complexity in provisioning machines directly as bare metal servers—here are our options using Ansible for declarative CI setups:
Options Using Self-Hosted Agents with GitHub Actions and Containers
- Ansible Role/Playbook Provision
- Use a combination of existing resources by registering your agents in the repositories where we define our pipelines (
workflow.yml
). This ensures that any new agent will be provisioned correctly with all necessary software when merged into main. The Ansible role and playbooks are crafted to handle:- Software installation, including JDK version selection as per pipeline requirements automatically upon merges indicating a change in dependency or tooling versions.
This method provides centralized control over infrastructure automation through anansible
repository which is tightly coupled with our CI processes—an elegant solution for deployments without manual intervention on each agent host machine after every software update approval like Java version changes.
- Software installation, including JDK version selection as per pipeline requirements automatically upon merges indicating a change in dependency or tooling versions.
- Use a combination of existing resources by registering your agents in the repositories where we define our pipelines (
- Containerizing Actions/Workflows
- By encapsulating the entire pipeline workflow into containers, we streamline deployment further and maintain a clear separation of concerns between container configurations (
workflow_containerized_.yml
) and environment setup (an Ansible role for building these custom images). Here’s how it integrates:- Containers built as per CI actions or GitHub Actions workflow requirements, with each build process tailored to specific project needs.
With this approach using Packer templates—a well-documented tool in HashiCorp’s documentation—we can declare our containerized environment configurations within the repository, ensuring that every build action operates inside a consistent and predefined runtime setting.
- Containers built as per CI actions or GitHub Actions workflow requirements, with each build process tailored to specific project needs.
- By encapsulating the entire pipeline workflow into containers, we streamline deployment further and maintain a clear separation of concerns between container configurations (
- Customize Runners in Existing Containers
- While using existing containers for your GitHub Actions workflow doesn’t necessitate full re-provisioning each time environment specifics change, customizing mount points within those Docker environments can accommodate specialized licensed software or dependencies unique to the project:
- This granular control allows us tailor agent behavior on a case by case basis without overhauling entire workflow systems.
By leveraging existing containers and selectively defining what’s mounted, we achieve flexibility within constraints that already bear Docker infrastructure—minimal overhead for container management while retaining full environment configuration capacity when required (e.g., specialized licensed software dependencies).
- This granular control allows us tailor agent behavior on a case by case basis without overhauling entire workflow systems.
- While using existing containers for your GitHub Actions workflow doesn’t necessitate full re-provisioning each time environment specifics change, customizing mount points within those Docker environments can accommodate specialized licensed software or dependencies unique to the project:
In summary: our chosen Ansible approach ensures a declarative manner to update the agents without manually setting up each one post-update, in line with maintaining efficient and automated CI processes within self-hosted environments using GitHub Actions workflows. The use of customizable containers further refines this process by allowing for specific needs or licensed dependencies while avoiding unnecessary Docker complexity on our part: