How do you inject secrets into a GitHub Actions job without them appearing in logs?
BeginnerScenarioSecrets and Identity Management
Answer
Situation read → GitHub masks registered secrets, but transformations (base64, substrings, JSON) can still leak them.
What I'd do →
- Store values as environment-scoped secrets with required reviewers on the
prodenvironment. - Pass them via
env:to the specific step, not to the whole job. - Mask derived values:
echo "::add-mask::$TOKEN". - Never
set -xin steps that touch secrets and never echo them. - Better still, fetch at runtime from Vault or a cloud store using OIDC so the value is never a repo secret.
Why → Masking is a safety net, not a control. Reduced scope and short life are the real controls.
Interview tip → Mention that secrets are not passed to workflows triggered from forks.
More on Secrets and Identity Management
A team stores database passwords in a `.env` file committed to a private repo. How do you migrate them out?BeginnerYour CI pipeline uses long-lived AWS access keys stored as repository secrets. How do you replace them?IntermediateAn auditor asks how often you rotate database credentials. You currently never do. What do you build?IntermediatePods need AWS access. A developer mounted an IAM user's keys as a Kubernetes Secret. What do you propose instead?BeginnerShould you use Kubernetes Secrets, Sealed Secrets, External Secrets Operator or the Secrets Store CSI driver?IntermediateA Slack webhook URL and a Stripe live key were posted in a public GitHub issue. What is your response sequence?Beginner