DevOpsGitHub

GitHub Actions: Reusable Workflows

TT
TopicTrick Team
GitHub Actions: Reusable Workflows

GitHub Actions: Reusable Workflows


1. What is a Reusable Workflow?

It's a workflow file that has the trigger workflow_call.

  • The "Called" Workflow: The template. It lives in a central repo (e.g., .github/workflows/deploy-template.yml).
  • The "Caller" Workflow: Your app's repo. It just says: "Use the template at 'my-org/core-repo' and send these variables."
  • The Benefit: If you update the "Template" to fix a security bug, all 20 apps are fixed instantly.

2. Composite Actions: The "Tiny" Reuse

If you only want to reuse a Sequence of Steps (e.g., "Install Node, Install dependencies, Build"), use a Composite Action.

  • It is faster for small tasks.
  • It's like creating a custom "Command" that you can use in any other action.
  • The Verdict: Use Reusable Workflows for "Whole Jobs" (Deployment) and Composite Actions for "Small Tasks" (Setup).

3. Inputs and Secrets: Passing Data

How does the template know which server to deploy to?

  • inputs: You pass strings like "production" or "staging".
  • secrets: inherit: In 2026, you can tell the template to "Inherit" all the caller's passwords automatically. This makes setup 10x faster because you don't have to define the secrets twice.

4. The Centralized "DevOps" Repository

Professional companies in 2026 have a dedicated repo called .github or devops-core.

  • This repo contains the "Gold Standard" workflows for the whole company.
  • The developers are the "Customers" who use these workflows.
  • This ensures that every app in the company is built with the same level of quality and security.

Frequently Asked Questions

Can I reuse a workflow from a private repo? YES. You just have to allow the "Access" in the settings. This is perfect for keeping your "Deployment Secrets" hidden from the public while still allowing all your internal teams to share the templates.

When should I NOT reuse? If a project is "Unique" and needs very specific steps that no one else needs, don't force it into a template. Reusability is for Consistency. If you try to build a "One size fits all" template that is $1,000$ lines of If statements, it becomes a nightmare to maintain.


Key Takeaway

Reusability is the "Scale" of DevOps. By mastering Reusable Workflows and the discipline of a centralized core repository, you gain the ability to manage $100$ projects with the same effort as $1$ project. You graduate from "Fixing individual workflows" to "Architecting a DevOps Platform."

Read next: GitHub Actions: Matrix Builds and Parallelism →


Part of the GitHub Mastery Course — engineering the reuse.