r/devops • u/tmg80 • Jul 28 '26
Tools github actions central repo
Hi I am in a new role where they use Github for all their repos. I have been using Gitlab exlusively the past 5 years.
For CI/CD in my previous role we had a central 'pipelines' repo that was reference in the gitlab-ci file of each project to save teams/projects from repeating work.
I want to know if it's possible to do something similar in Github? I'm still learning how it maps to my existing Gitlab knowledge.
27
Upvotes
19
u/fletch3555 Lead DevOps Engineer Jul 28 '26
https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows
14
u/Due-Consequence9579 Jul 28 '26
Path of least resistance on GHA is poly repo actions that implement atomic actions unique to your org, think tagging standards, artifact publishing, etc. Then instead of reusable workflows using composite GHA to tape everything together into broader pipelines like “build a java project”. Individual repos have a .github/workflows/build.yml that just does triggers and passes whatever configuration you need to into the wrapping composite action.
The ergonomics around reusable workflows is not great in my experience.
7
u/PerpetuallySticky Jul 28 '26
Yes as others have said it’s called reusable workflows.
A word of caution that you may run into and bang your head against a wall for a while with (someone please tell me if they fixed this):
Reusable workflows cannot be used with environment variables. However that information is passed on the backend, they do not work (last time I tried). Example:
Reusable workflow A (A)
Repo B uses reusable workflow A (B)
A has an input variable to set what environment it should run in.
B has environment variables set and tries to pass one for the environment when it uses A. That variable will not pass. It errors out and acts like nothing passes at all.
Not completely sure why it happens, but it has stopped our widespread adoption of reusable workflows
4
u/CommeGaston Jul 28 '26
Reusable workflows - but they have various limitations.
You can couple them with Composite Actions to get around some of them.
2
u/kabrandon Jul 28 '26
Funnily enough this is basically the only thing that GitHub Actions is famously better at than GitLab CI at doing. Yes, you can do this with GitHub Actions.
2
u/Floss_Patrol_76 Jul 28 '26
the thing that tripped me up coming from gitlab is there's no include: that just splices yaml in, so you split it two ways: reusable workflows (uses: org/repo/.github/workflows/x.yml@ref) for whole-job or whole-pipeline reuse, and composite actions for a few steps you paste everywhere. rule of thumb: if it's a job with its own runner it's a reusable workflow, if it's steps inside a job it's a composite action. heads up that you can't nest reusable workflows more than a couple levels, so don't try to rebuild gitlab's include hierarchy 1:1.
1
u/pdfops Jul 28 '26
Reusable workflows are the GitHub equivalent. Shared workflow lives in one repo's .github/workflows/ with
on: workflow_call, other repos call it viauses: org/repo/.github/workflows/build.yml@main. For just shared steps instead of whole jobs, composite actions are closer to GitLab includes. Gotcha: secrets don't auto-pass, you needsecrets: inheriton the caller.1
u/Raja-Karuppasamy Jul 28 '26
yeah, github actions has this, reusable workflows. define a workflow with workflow_call as the trigger in a central repo, then other repos reference it like:
jobs:
build:
uses: org/central-repo/.github/workflows/build.yml@main
with:
some-input: value
it’s not 1:1 with gitlab’s include, but the effect is the same, one source of truth, versioned by branch/tag, and each project just passes inputs. composite actions are the other option if you want shared steps rather than a whole job/workflow, but reusable workflows are the closer match to what you’re describing.
1
u/marcusbell95 Jul 28 '26
yeah this is the one area github actually did better than gitlab out of the box. equivalent to your central pipelines repo: make any shared repo (ours is called pipeline-templates). put your reusable workflows in .github/workflows/ there. each project workflow then references them with `uses: your-org/pipeline-templates/.github/workflows/build.yml@main` plus whatever inputs it needs. two things that bit us on this migration: first, add `secrets: inherit` to every caller - without it the reusable workflow can't see any repo or org secrets and fails silently, took a day to debug. second, env vars don't pass through the way gitlab includes do, use inputs for config values instead. composite actions are the step-level version of this but they don't span multiple jobs - if your gitlab templates orchestrate whole stages, reusable workflows are what you want.
1
u/avski Jul 29 '26
I hear gitlab is offering $0 first year contracts for GitHub take outs - would you consider this route ?