Skip to main content
In this lesson, you’ll learn how to securely pass secrets into a reusable GitHub Actions workflow. We’ll cover:
  • Inspecting a reusable workflow to identify required secrets
  • Two approaches for passing secrets
  • A step-by-step guide to explicitly declare and pass secrets
  • Common pitfalls and how to propagate environment variables

Inspecting the Reusable Workflow

First, review the reusable workflow metadata to see which secrets it expects:
A quick search shows this workflow requires two secrets: These must be supplied by the caller workflow (the “Solar System Workflow”).

Caller Workflow Example

Here’s how you might create a Kubernetes secret and deploy in your caller workflow:

Approaches to Passing Secrets

You have two main methods for forwarding secrets to a reusable workflow:
Using secrets: inherit is quick, but explicit declaration reduces blast radius by only passing the secrets you need.

Step-by-Step: Explicitly Passing Secrets

Follow these steps to declare and forward secrets in your reusable workflow.

1. Declare Secrets in the Reusable Workflow

Add a secrets section under workflow_call:

2. Call the Reusable Workflow with Secrets

Reference the reusable workflow from your Solar System repo and pass the required secrets:
If a required secret is missing, the workflow will fail to start with an “invalid workflow file” error. Always verify secret names and availability before committing.
Successful execution will show:

Limitation: Environment Variables Aren’t Propagated

Note that environment variables (e.g., MONGO_URI) defined in the caller do not automatically flow into a reusable workflow:
In the Create MongoDB Secret logs, you’ll see an empty URI:
We’ll cover strategies to propagate environment variables across workflows in the next lesson.

Solar System Workflow (Caller)

Below is a complete example of your Solar System Workflow, showing how to set environment variables and call the reusable deployment workflow:

Watch Video