Migrate GitHub Actions Workflows to Ubuntu-slim with gh-slimify
Job to be done: Safely migrate GitHub Actions workflows to Ubuntu-slim runners
🇳🇬 Ways to use this in Nigeria
Ideas to get you started, adapt to your situation.
- Entrepreneur
Cut down the monthly CI/CD spend for your startup's MVP or product deployment by automatically migrating compatible GitHub Actions workflows to the cheaper `ubuntu-slim` runner.
- 9-5 employee
As a software engineer, identify and automatically update GitHub Actions workflows for your company's internal tools or client projects to use `ubuntu-slim` runners, reducing monthly CI/CD expenses.
- Student
Identify which GitHub Actions workflows for your final year project or side hustle web app can safely switch to `ubuntu-slim` runners to save on CI/CD costs.
What you’ll get
You will get an automated analysis of your GitHub Actions workflows to determine which can be safely migrated to the more cost-effective ubuntu-slim runner. This approach works by scanning your repository for common incompatibilities like Docker usage, services, or missing packages, allowing you to reduce your CI/CD costs without breaking your builds.
Tools you need
- gh-slimify (free) - A GitHub CLI extension to analyze and update GitHub Actions workflows.
- GitHub CLI (free) - A command-line interface for GitHub, used to install and run gh-slimify.
- LLM agent (freemium) - An AI model that can be prompted to perform similar analysis, useful for understanding the logic or for integration into other AI workflows.
Steps
-
Install GitHub CLI: If you don’t have it already, download and install the GitHub CLI from its official website. Follow the installation instructions for your operating system. You should see confirmation that the CLI is installed, and you can run
gh --versionto check. -
Install gh-slimify extension: Open your terminal or command prompt and run the following command to install the gh-slimify extension for GitHub CLI:
gh extension install fchimpan/gh-slimifyYou should see output indicating that the extension was successfully installed.
-
Analyze your workflows: Navigate to your GitHub repository’s directory in your terminal. Then, run the following command to analyze your existing GitHub Actions workflows:
gh slimifyThe tool will scan your
.github/workflowsdirectory. You should see output detailing which jobs are safe to migrate, which have potential issues, and which are incompatible withubuntu-slimrunners. -
Update safe workflows (optional): If you want gh-slimify to automatically update the workflows that are identified as safe to migrate, run:
gh slimify fixThis command will modify your workflow files in place, changing
ubuntu-latesttoubuntu-slimfor the safe jobs. Review the changes carefully before committing them. -
Analyze with an LLM agent (alternative): As an alternative or supplement, you can use an LLM agent. The author provides a prompt in the README. A starting point for such a prompt, based on the tool’s description, would be:
Analyze the following GitHub Actions workflow file content to determine if it is safe to migrate from 'ubuntu-latest' to 'ubuntu-slim'. Consider potential issues such as Docker usage, reliance on services, containers, specific package dependencies not present in the slim image, or step failures due to missing commands. List any detected incompatibilities or risks. [Paste your workflow YAML content here]You should receive a textual analysis from the LLM agent outlining potential migration risks.
Original source
This workflow is based on a tool called gh-slimify, created by r4mimu and shared on Hacker News. The tool is designed to help developers safely migrate their GitHub Actions workflows to the more economical ubuntu-slim runner by automating the detection of compatibility issues.
Notes & variations
- Free Tier Viability:
gh-slimifyandGitHub CLIare entirely free and open-source. LLM agents often have generous free tiers suitable for this kind of analysis. - Common Pitfall: Running
gh slimify fixwithout first reviewing the output ofgh slimifycan lead to unexpected build failures if the tool incorrectly identifies a workflow as safe. Always inspect the changes before committing. - Better Results: For more complex workflows, consider manually reviewing the output of
gh slimifyand cross-referencing with the officialubuntu-slimrunner documentation to understand exactly why certain jobs are flagged as incompatible.