On GitHub, secrets are stored in GitHub Actions Secrets and Dependabot Secrets. These are encrypted and can be used in workflows securely.
- Go to your repository on GitHub.
- Click on "Settings" (⚙️).
- Scroll down and click on "Secrets and variables" → "Actions".
- Click "New repository secret".
- Enter the name of the secret (e.g.,
GOOGLE_TRANSLATE_API_KEY
). - Paste the secret value (e.g., API key, password, or token).
- Click "Add secret".
Once stored, you can access them in your workflow using the ${{ secrets.SECRET_NAME }}
syntax.
jobs:
example_job:
runs-on: ubuntu-latest
steps:
- name: Access Secret
run: echo "My secret is ${{ secrets.MY_SECRET }}" # Never echo secrets in real workflows!
echo
), as they can be exposed in logs.
- Organization Secrets (For all repositories in an organization)
- Environment Secrets (Scoped to specific environments like
staging
,production
) - Dependabot Secrets (For managing dependency updates)
- Rotate secrets regularly.
- Use GitHub Environments for different scopes (e.g.,
dev
,prod
). - Never hardcode secrets in your repo.
Need help integrating secrets into a specific workflow? 🚀