How to Migrate a Jenkins Shared Library to a Reusable Workflow
A Jenkins shared library centralizes pipeline logic; the Actions equivalent is a reusable workflow called with workflow_call, or a composite action for step groups.
Jenkins shared libraries expose reusable steps and pipelines across repos. In Actions, put the shared pipeline in a workflow with on.workflow_call and call it, or bundle step groups into a composite action.
Concept mapping
| Jenkins | GitHub Actions |
|---|---|
shared library vars/*.groovy | reusable workflow (workflow_call) |
| library step used inline | composite action (runs.using: composite) |
@Library reference | uses: org/repo/.github/workflows/x.yml@ref |
| library parameters | inputs: and secrets: |
Reusable workflow (callee)
.github/workflows/build.yml
on:
workflow_call:
inputs:
node-version: { type: string, default: '20' }
secrets:
NPM_TOKEN: { required: true }
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- run: npm ci && npm run buildCaller
.github/workflows/ci.yml
jobs:
call:
uses: my-org/ci/.github/workflows/build.yml@main
with:
node-version: '20'
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}What does not map cleanly
- Groovy helper logic does not port; rewrite it as shell or a small action.
- Reusable workflows nest at most four levels deep.
- A composite action shares steps, not whole jobs; use
workflow_callwhen you need jobs.
Related guides
How to Migrate a Declarative Jenkinsfile to GitHub ActionsTranslate a declarative Jenkins pipeline to GitHub Actions, mapping stages to jobs, agents to runners, and th…
How to Migrate Reusable Pipeline Patterns to GitHub ActionsReplace GitLab templates, CircleCI orbs, and YAML anchors with GitHub Actions reusable workflows and composit…