Warning
Migrating to ubuntu-slim may cause workflow instability or increased execution time.
Tip
π‘ Wait, couldn't you just copy-paste the following prompt into AI agent and skip using this tool altogether? π€
Goal: For every workflow file under `.github/workflows`, migrate jobs that currently run on `ubuntu-latest` to the container-based runner `ubuntu-slim`. Use the following decision rules in order when judging whether to migrate a job:
1. Only consider jobs (including matrix entries) whose `runs-on` is `ubuntu-latest` or `ubuntu-24.04`.
2. Skip any job that uses service containers (`jobs.<job_id>.services`).
3. Skip any job already running inside a container (`jobs.<job_id>.container`).
4. Skip any job whose setup steps provision an environment that assumes a non-container host.
5. Skip any job whose run scripts rely on host-only commands or elevated system privileges that containers cannot provide (e.g., `mount`, `iptables`, `modprobe`, `sysctl`, `nsenter`, `systemctl`, `systemd`, etc.).
6. Skip any job whose execution time exceeds 15 minutes. Use the GitHub CLI to check the duration of the most recent successful run. Example commands:
```bash
# Get the database ID of the latest successful run
id=$(gh run list \
--repo ${owner}/${repo} \
--workflow ${workflow_file_name} \
--status success \
--limit 1 \
--json databaseId | jq .'[0].databaseId')
# List jobs from that run to inspect start/completion times
gh api \
repos/{owner}/{repo}/actions/runs/${id}/jobs | jq '.jobs[] | {name: .name, started_at: .started_at, completed_at: .completed_at}'
Based on these rules, review each workflow and migrate every eligible job to ubuntu-slim. Afterward, report both the jobs that were successfully migrated and, for those that were not, the specific reasons they were ineligible.GitHub Actions recently introduced the lightweight ubuntu-slim runner (1 vCPU / 5 GB RAM, max 15 min runtime) as a cost-efficient alternative to ubuntu-latest. However, manually identifying which workflows can safely migrate is tedious and error-prone:
- β Jobs using Docker commands or containers cannot migrate
- β Jobs using
services:containers are incompatible - β Jobs exceeding 15 minutes will fail
- β Container-based GitHub Actions are not supported
- β Jobs using privileged operations (e.g.,
mount,iptables,modprobe) are incompatible
gh-slimify automates this entire process, analyzing your workflows and safely migrating eligible jobs with a single command.
Install as a GitHub CLI extension:
gh extension install fchimpan/gh-slimifyNote
The built-in list of tools pre-installed on ubuntu-slim is a snapshot of the runner image and may drift as GitHub updates it weekly. See the official ubuntu-slim installed software list for the current state, and always verify manually before migrating critical workflows.
Important
All commands must be executed from the repository root directory (where .github/workflows/ is located).
Get help:
$ gh slimify --helpScan specific workflow file(s) to find migration candidates:
gh slimify .github/workflows/ci.ymlOr scan multiple workflow files:
gh slimify .github/workflows/ci.yml .github/workflows/test.ymlTo scan all workflows in .github/workflows/, use the --all flag:
gh slimify --allExample Output:
π .github/workflows/lint.yml
β
Safe to migrate (1 job(s)):
β’ "lint" (L8) - Last execution time: 4m
.github/workflows/lint.yml:8
β οΈ Can migrate but requires attention (1 job(s)):
β’ "build" (L15)
β οΈ Setup may be required (go), Last execution time: unknown
.github/workflows/lint.yml:15
β Cannot migrate (2 job(s)):
β’ "docker-build" (L25)
β uses Docker commands
.github/workflows/lint.yml:25
β’ "test-with-db" (L35)
β uses service containers
.github/workflows/lint.yml:35
β
1 job(s) can be safely migrated
β οΈ 1 job(s) can be migrated but require attention
β 2 job(s) cannot be migrated
π Total: 2 job(s) eligible for migration
The output shows:
- β Safe to migrate: Jobs with no missing commands and known execution time
β οΈ Can migrate but requires attention: Jobs with missing commands or unknown execution time- β Cannot migrate: Jobs that cannot be migrated with specific reasons (e.g., uses Docker commands, uses service containers, uses container syntax, does not run on ubuntu-latest)
- Warning reasons: Displayed in a single line for easy understanding
- Relative file paths: Clickable links that work in VS Code, iTerm2, and other terminal emulators
Automatically update eligible jobs to use ubuntu-slim. By default, only safe jobs (no missing commands and known execution time) are updated.
Specify workflow file(s):
gh slimify fix .github/workflows/ci.ymlOr use --all to fix all workflows:
gh slimify fix --allExample Output (default - safe jobs only):
Updating workflows to use ubuntu-slim (safe jobs only)...
Skipping 1 job(s) with warnings. Use --force to update them.
Updating .github/workflows/lint.yml
β Updated job "lint" (L8) β ubuntu-slim
Successfully updated 1 job(s) to use ubuntu-slim.
To also update jobs with warnings (missing commands or unknown execution time), use the --force flag:
gh slimify fix --forceExample Output (with --force):
Updating workflows to use ubuntu-slim (including jobs with warnings)...
Updating .github/workflows/lint.yml
β οΈ Updated job "build" (L15) β ubuntu-slim (with warnings)
β Updated job "lint" (L8) β ubuntu-slim
Successfully updated 2 job(s) to use ubuntu-slim.
To scan all workflows in .github/workflows/, use the --all flag:
gh slimify --allYou can also use the --file (or -f) flag to specify workflow files:
gh slimify -f .github/workflows/ci.yml -f .github/workflows/test.ymlSkip fetching job durations from GitHub API. This is useful for:
- API rate limit management: Avoid hitting GitHub API rate limits when scanning many workflows
- Faster scans: Skip API calls for quicker results
- When API access is unavailable: Use when GitHub API is not accessible
gh slimify --skip-durationSkip all GitHub API access β job durations and remote action metadata. Docker-action detection falls back to offline heuristics (docker/ prefix, docker:// images, local action.yml files); execution times are reported as unknown.
gh slimify --offline --allUse the --verbose flag to enable debug output, which can help troubleshoot issues with API calls or workflow parsing:
gh slimify --verboseUpdate jobs with warnings (missing commands or unknown execution time):
gh slimify fix --forceUse --json to output results in machine-readable JSON format. This is useful for CI/CD pipelines, AI agents, or other tools that need to parse the results programmatically.
gh slimify --json --all
gh slimify fix --json --allExample scan output:
{
"jobs": [
{
"workflow_path": ".github/workflows/ci.yml",
"job_id": "lint",
"job_name": "Lint",
"line_number": 8,
"status": "safe",
"status_description": "Safe to migrate to ubuntu-slim. No missing commands and execution time is known.",
"recommended_action": "migrate",
"duration_seconds": 143
},
{
"workflow_path": ".github/workflows/ci.yml",
"job_id": "build",
"job_name": "Build",
"line_number": 25,
"status": "warning",
"status_description": "Can migrate but requires attention. Setup may be required for: docker.",
"recommended_action": "review_before_migrate",
"duration_seconds": 230,
"missing_commands": ["docker"]
}
],
"summary": {
"safe": 1,
"warning": 1,
"ineligible": 0,
"already_slim": 0,
"total": 2
}
}Scan job statuses:
| Status | Recommended Action | Description |
|---|---|---|
safe |
migrate |
Safe to migrate, no issues found |
warning |
review_before_migrate |
Can migrate but has missing commands or unknown duration |
ineligible |
do_not_migrate |
Cannot migrate to ubuntu-slim |
already_slim |
no_action_needed |
Already using ubuntu-slim |
Fix job statuses:
| Status | Recommended Action | Description |
|---|---|---|
updated |
verify_workflow |
Successfully updated to ubuntu-slim |
updated (with warnings) |
verify_workflow_carefully |
Updated but requires careful verification |
skipped |
review_then_force |
Skipped due to warnings, use --force to update |
error |
investigate_error |
Failed to update |
not_found |
investigate_error |
Job not found in workflow file |
gh slimify fix .github/workflows/ci.yml --skip-duration --force
gh slimify --all --skip-duration
gh slimify fix --all --force
gh slimify --json --all --skip-durationA job is eligible for migration to ubuntu-slim if all of the following conditions are met:
- β
Runs on
ubuntu-latestorubuntu-24.04with a single label (multi-labelruns-onarrays target self-hosted runners and are skipped; reusable workflow calls and expression-basedruns-onsuch as${{ matrix.os }}are reported with their own reasons) - β
Does not invoke container tooling β
dockerwith any subcommand (build,buildx,run,load,save, ...),docker-compose,podman,nerdctl,buildahβ including invocations passed tobash -c,eval, or heredocs. Run scripts are parsed as shell, so command names inside comments or string arguments do not cause false positives. - β
Does not use Docker-based GitHub Actions. The
docker/organization anddocker://images are detected offline; for other publishers the tool fetches each action's metadata (runs.using: docker) from the GitHub API β catching Dockerfile-based actions likesuper-linter/super-linterorhadolint/hadolint-actionβ and follows nested composite actions. Local actions (uses: ./path) are read from disk. If metadata cannot be fetched (offline, rate limit), detection falls back to the prefix heuristics. - β
Does not use
services:containers (PostgreSQL, Redis, MySQL, etc.) - β
Does not use
container:syntax (jobs running inside Docker containers) - β
Does not invoke privileged operations (
mount,iptables,modprobe,sysctl,nsenter, etc.) - β Latest successful run duration is under 15 minutes (checked via GitHub API). Jobs over the limit are reported as cannot migrate; jobs over 10 minutes are flagged with a warning because ubuntu-slim's single vCPU is often slower than ubuntu-latest.
β οΈ Jobs using commands that exist inubuntu-latestbut not inubuntu-slimwill be flagged with warnings but are still eligible for migration. You may need to add setup steps to install these tools inubuntu-slim.
Note
Setup Action Detection: If a job uses popular setup actions from GitHub Marketplace (e.g., actions/setup-go,hashicorp/setup-terraform), the commands provided by those actions (e.g., go, terraform) will not be flagged as missing. This is because these setup actions install the necessary tools, making the job safe to migrate. The tool recognizes setup actions from GitHub Marketplace's verified creators, including official GitHub actions and popular third-party actions.
If any condition is violated, the job will not be migrated.
Jobs are classified into three categories:
- β Safe to migrate: No missing commands, execution time is known and comfortably under the limit
β οΈ Can migrate but requires attention: Has missing commands, execution time is unknown, or the last run exceeded 10 minutes (close to the 15-minute limit on a slower 1 vCPU runner)- β Cannot migrate: Does not meet migration criteria (e.g., uses Docker commands, uses service containers, uses container syntax, does not run on ubuntu-latest, last execution time exceeds the 15-minute limit)
Missing commands are tools that exist in ubuntu-latest but need to be installed in ubuntu-slim (e.g., nvm). These jobs can still be migrated, but you may need to add setup steps to install the required tools.
When a job cannot be migrated, the specific reason(s) are displayed, such as:
- "does not run on ubuntu-latest or ubuntu-24.04"
- "calls a reusable workflow (its runner is defined in the called workflow)"
- "runs-on is set by an expression (e.g. matrix) and was not analyzed"
- "uses multiple runner labels (self-hosted runner)"
- "uses Docker commands"
- "uses container-based GitHub Actions"
- "uses Docker container action(s) (hadolint/hadolint-action@v3.1.0)"
- "uses service containers"
- "uses container syntax"
- "uses privileged operations (mount, iptables, ...)"
- "last execution time (23m) exceeds ubuntu-slim's 15-minute limit"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm run lintjobs:
build:
runs-on: ubuntu-latest
steps:
- uses: docker/build-push-action@v6
with:
context: .
push: trueResult: β Not eligible β Uses Docker-based action
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
steps:
- run: npm testResult: β Not eligible β Uses services: containers
jobs:
test:
runs-on: ubuntu-latest
container:
image: node:18
steps:
- run: node --versionResult: β Not eligible β Uses container: syntax
jobs:
network-test:
runs-on: ubuntu-latest
steps:
- run: |
sudo iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
sudo sysctl -w net.ipv4.ip_forward=1Result: β Not eligible β Uses privileged operations (iptables, sysctl)
- Parse Workflows: Scans
.github/workflows/*.ymlfiles and parses job definitions - Check Criteria: Evaluates each job against migration criteria (Docker, services, containers)
- Detect Missing Commands: Identifies commands used in jobs that exist in
ubuntu-latestbut not inubuntu-slim - Fetch Durations: Retrieves latest job execution times from GitHub API (unless
--skip-durationis used) - Classify Jobs: Separates jobs into "safe" (no warnings), "requires attention" (has warnings), and "cannot migrate" (does not meet criteria) categories
- Report Results: Displays eligible jobs grouped by status with:
- Visual indicators (β
for safe,
β οΈ for warnings, β for ineligible) - Ineligibility reasons for jobs that cannot be migrated
- Warning reasons in a single line
- Relative file paths with line numbers (clickable in most terminals)
- Execution durations
- Machine-readable JSON output (
--json) with status descriptions and recommended actions for AI agents and automation
- Visual indicators (β
for safe,
- Auto-Fix (optional): Updates
runs-on: ubuntu-latesttoruns-on: ubuntu-slim:- By default: Only safe jobs are updated
- With
--force: All eligible jobs (including those with warnings) are updated
MIT License
