Skip to main content
By centralizing common jobs—like deployment—into standalone workflows, you can reduce duplication, simplify updates, and enforce best practices across all your repositories. This guide shows you how to extract deployment logic into a reusable workflow and invoke it from language-specific CI pipelines.

Sample CI Workflow for a Node.js App

Here’s an example .github/workflows/ci-testing.yml that runs tests, coverage, dependency scanning, build, and deployments in sequence:
Copy-pasting deployment steps across multiple workflows leads to fragmented updates and higher maintenance costs. A single change requires edits in every file.

Why Use Reusable Workflows?

A reusable workflow is a YAML file that other workflows can invoke via workflow_call. Benefits include:

Example Repository Layout

Assume the following structure in your XYZ/nodejs-app-repo:
  • .github/workflows/awesome-app.yaml
  • .github/workflows/reusable-workflow.yaml

Original Workflow: awesome-app.yaml

This caller workflow builds the app, runs tests, and then invokes the reusable deployment job:

Reusable Workflow: reusable-workflow.yaml

By declaring on.workflow_call, you expose inputs, secrets, and jobs that any caller workflow can use:

Invoking the Reusable Workflow

You can call this reusable workflow from any repository or branch:
Inputs and secrets are strongly typed. Ensure that every workflow_call declaration and invocation matches the expected names and types.

Key Terminology

  • Caller workflow: The YAML file that uses uses: to invoke a reusable workflow.
  • Called workflow: The reusable workflow that declares on.workflow_call.

Watch Video