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:
2. Declare Secrets in the Reusable Workflow
Extend theon.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.
5. Verify Workflow Execution
After adding the secrets, thedev-deploy job should complete the Kubeconfig step successfully. If you still see empty environment variables in downstream jobs, like:
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:Links and References
- Reusing Workflows with workflow_call
- GitHub Actions Encrypted Secrets
- azure/setup-kubectl Action
- azure/k8s-set-context Action