Skip to main content
In this guide, you’ll learn how to pass inputs into GitHub Actions reusable workflows to handle configuration values—such as MongoDB credentials—without relying on environment variables in the caller workflow.
Environment variables defined in a caller workflow do not propagate into a called reusable workflow. Attempting to pass sensitive data like database URIs via env: will result in empty values.
For example, this command fails to set MONGO_URI:
This is a documented limitation of reusable workflows.
The image shows a GitHub Docs page about GitHub Actions, specifically focusing on the limitations of reusing workflows. It includes navigation menus and detailed text on workflow limitations.

1. Define a Basic Reusable Workflow

Create a workflow—e.g. .github/workflows/reuse-deployment.yml—that declares the required secrets under workflow_call. This allows callers to supply kubeconfig and database passwords securely:

2. Store MongoDB URI as a Repository Variable

Go to Settings > Actions > Secrets and variables > Variables and add:
  • Name: MONGO_URI
  • Value: mongodb+srv://supercluster.d8jj.mongodb.net/superData
Now the workflow can reference env.MONGO_URI without relying on the caller’s env: block.
The image shows a GitHub repository settings page focused on "Actions secrets and variables," displaying environment variables and options to manage them. The interface includes sections for secrets, variables, and various repository settings.

3. Add workflow_call Inputs

Enhance your reusable workflow by defining typed inputs for maximum flexibility:

Inputs Reference Table

Update steps to reference inputs instead of hard-coded values:

4. Call the Reusable Workflow with Inputs

In your caller workflow (e.g. .github/workflows/dev-deploy.yml), pass inputs via with: and secrets as before:
After pushing, the dev-deploy run shows the inputs and secrets correctly applied:
The image shows a GitHub Actions workflow interface with a series of jobs and their statuses, including unit testing, code coverage, and deployment steps. The workflow is in progress, with some jobs completed and others waiting.
You’ll see:
  • mongodb-uri sourced from the repository variable.
  • kubectl-version defaulting to v1.26.0 unless overridden.
  • The manifest directory and environment matching the with: values.
The MongoDB secret creation now succeeds:
The image shows a GitHub Actions workflow interface with a list of jobs and their statuses, including unit testing, code coverage, and deployment tasks. Some jobs are marked as successful, while others have failed.
If you need outputs (like APP_INGRESS_URL) in the caller workflow, use outputs in the reusable workflow and capture them via the needs context.

Watch Video