Managing Secrets in GitHub Actions
Discover how to securely configure and optimize your TestDriver environment for seamless CI/CD workflows.
Overview
When using TestDriver to test your application, you may need to securely store and use sensitive information such as usernames, passwords, API keys, or other secrets. GitHub Actions provides a secure way to manage these secrets, ensuring they aren’t exposed in your test files or logs.
Why use secrets?
- Security: Secrets are encrypted and stored securely in your GitHub repository.
- Masking: TestDriver automatically masks secrets in all test output, including debugging logs.
- Reusability: Secrets can be reused across multiple workflows and test files.
Step 1: Replace hardcoded secrets in test files
To securely use secrets in your TestDriver test files, replace hardcoded values with placeholders in the format ${TD_YOUR_SECRET}
. TestDriver will parse and mask any secrets that begin with TD_
.
Example test file
Step 2: Add secrets to Your GitHub repository
- Navigate to your GitHub repository.
- Go to Settings > Secrets and variables > Actions.
- Click New repository secret.
- Add your secrets (for example,
TD_USERNAME
,TD_PASSWORD
,TD_API_KEY
).
For detailed instructions, refer to the GitHub Docs on using secrets.
Step 3: Supply secrets to GitHub Actions
When running TestDriver tests via GitHub Actions, supply your secrets in the env
section of the workflow file.
Example workflow
Best practices
- Use Descriptive Names: Name your secrets clearly (for example,
TD_USERNAME
,TD_PASSWORD
) to make them easy to identify. - Rotate Secrets Regularly: Update your secrets periodically to enhance security.
- Limit Access: Only provide access to secrets for workflows and team members that require them.
- Mask Secrets: Ensure all secrets are masked in logs by using the
TD_
prefix.
Notes
- Secrets are encrypted and only accessible during the workflow run.
- TestDriver automatically masks secrets in test output to prevent accidental exposure.
- For additional security, avoid hardcoding sensitive information in your test files or workflows.