How to use a custom transformer to map CI/CD runner labels and centralize environment variable mappings when migrating pipelines to GitHub Actions
In this lesson you will learn how to use a custom transformer to translate source CI/CD runner labels into equivalent GitHub Actions runners and to centralize environment variable mappings. This is useful when migrating pipelines (for example, from Jenkins) that reference self-hosted agents or custom labels so they run on GitHub-hosted runners like ubuntu-latest.
What the transformer provides
A runner helper to map a source runner label to one or more GitHub Actions runner labels.
env helpers to centralize environment variables or map them to repository secrets.
First parameter: source CI/CD runner label (string).
Second parameter: GitHub Actions label(s), either a string or an array of strings.
Dry-run the importer to preview generated workflows
Run a one-time dry-run of the importer to produce the converted workflow files (trimmed output shown):
Original converted workflow (example)
Some jobs in the converted workflow may still reference self-hosted runner labels and agent-specific labels, for example:
Update the transformer to map runners and envs
To replace source labels with GitHub-hosted runners and to centralize environment variables, add mappings at the top of your transformer file (for example ss-pipeline-transformer.rb).Example transformer mappings:
# Map environment variables (set literal or map to secrets)env "MONGO_USERNAME", "superuser"env "MONGO_PASSWORD", secret("mongo_db_password")env "MONGO_DB_CREDS", nil# Map Jenkins/JB agent label to GitHub Actions runnerrunner "us-west-1-ubuntu-22", "ubuntu-latest"
When writing the mapping lines, ensure correct Ruby syntax (commas between parameters). For instance: runner "us-west-1-ubuntu-22", "ubuntu-latest".
Re-run the dry-run with your custom transformer
After saving the transformer, run the dry-run again to regenerate the workflow with the mapped runners and centralized env entries: