Skip to main content
In this guide, we’ll demonstrate how to securely pass secrets to a reusable GitHub Actions workflow. Centralizing deployment logic and managing sensitive data in one place improves maintainability and security.

1. Inspect the Existing Reusable Workflow

Open the reusable workflow file at .github/workflows/reuse-deployment.yml:
A quick review shows this workflow expects two secrets:

2. Declare Secrets in the Reusable Workflow

Extend the on.workflow_call section to require these secrets:
Declaring secrets under on.workflow_call ensures GitHub Actions validates them before running any jobs.

3. Pass Secrets from the Caller Workflow

In your caller workflow (for example, .github/workflows/solar-system.yml), supply the required secrets under each job that invokes the reusable workflow:

4. Handle Missing Secrets Errors

If you omit a required secret, GitHub Actions fails immediately with a validation error specifying the missing secret.
Ensure each job includes all declared secrets to prevent startup failures.

5. Verify Workflow Execution

After adding the secrets, the dev-deploy job should complete the Kubeconfig step successfully. If you still see empty environment variables in downstream jobs, like:
remember that GitHub Actions does not automatically propagate caller env variables into a reusable workflow’s outputs. You may need to explicitly map and return those variables.

6. Example Caller Workflow Environment

For context, here’s how global environment variables might be defined in the caller workflow:

Watch Video