Git & GitHub Interview Question #95
What are GitHub Actions variables and how are they different from secrets?
GitHub Collaboration, Repository Rules, Issues, Releases & Actions CI/CD Mid-Level Intermediate
Quick Interview Answer
Configuration variables store non-sensitive configuration values that workflows can reference. Secrets are intended for sensitive values and receive additional protection and masking behavior.
Detailed Explanation
Configuration variables store non-sensitive configuration values that workflows can reference. Secrets are intended for sensitive values and receive additional protection and masking behavior.
Do not place passwords, access tokens, private keys, or other credentials in ordinary variables simply because they are convenient. Choose the storage mechanism according to the sensitivity of the value.
Code Example
steps:
- name: Show environment name
run: echo "${{ vars.APP_ENVIRONMENT }}"
- name: Use protected credential
env:
TOKEN: ${{ secrets.DEPLOY_TOKEN }}
run: ./deploy.sh