Answer
Use a secret manager or protected CI secret store, grant minimal access, and prevent secrets from entering source files, logs, or build artifacts.
Explanation
Masking logs is helpful but cannot make arbitrary disclosure safe.
Example
The deploy job receives a narrowly scoped credential only when needed.