AI Hints
CI/CD with GitHub Actions · Lesson 128 of 138

Interview Question 2

Keeping secrets safe.

⏱ 2 min read▶ Video at 2:29:00🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

Second question. How do you handle secrets, like passwords and keys, in a CICD pipeline? This tests whether you think about security.

Interview Question 2
From the video: Interview Question 2
  • How do you handle secrets?
  • Passwords and keys
  • A security question

A strong answer

Never commit secrets to the repository. Store them in the platform's encrypted secrets, ideally per environment, so production keys are only used by approved deploys. Prefer OIDC over long lived cloud keys. And give tokens the least privilege they need.

keyvalue
Never in gituse encrypted secrets
Per environmentprod keys protected
OIDCno long-lived keys
Least privilegeminimal permissions

Bonus points

Mention the risks too. Pull request target, and untrusted input in scripts, can leak secrets. Pin third party actions. Use secret scanning, and push protection. And if a secret leaks, revoke and rotate it immediately.

keyvalue
Untrusted inputuse env variables
Pin actionsto SHAs
Secret scanningpush protection
Leaked?revoke and rotate

A likely follow-up

A follow up might be, a secret was committed to a public repository an hour ago. What now? Revoke it first, because bots may already have it. Then create a new one, and update the secret store. Remove it from the history if needed. And check the logs of that service, for any use of the old key.

keyvalue
1. Revokeright away
2. Rotatenew key, update secrets
3. Clean uphistory if needed
4. Investigatecheck usage logs

Summary

Encrypted secrets per environment, OIDC, least privilege, and a fast response to leaks. Next, a question about a slow, flaky pipeline.

Key takeaways
  • Encrypted secrets
  • OIDC
  • Revoke leaks
Next up: Interview Question 3 — fixing a bad pipeline