CI/CD & GitHub Actions (50 Qs)•Part 1: CI/CD Fundamentals & GitHub Actions Core (Junior / Entry-Level)
How are secrets and environment variables managed securely?
junior LevelMost AskedCode ExampleState ManagementCI/CD & DevOps
In Simple Words:
- Repository Secrets: Encrypted values stored at the repository or organization level (e.g., API keys, deployment tokens). GitHub automatically masks secrets in console logs.
- Environment Secrets: Scoped to specific environments (e.g.
production,staging). Access can be restricted by deployment branch policies and required approvers. GITHUB_TOKEN: A short-lived token automatically provisioned for each job. Its permissions should follow the principle of least privilege using top-levelpermissions:.
yaml
permissions:
contents: read
packages: write
id-token: write # Required for AWS OIDC
jobs:
deploy:
runs-on: ubuntu-latest
environment: production # Uses production secrets & requires approvals
steps:
- name: Deploy
env:
DATABASE_URL: ${{ secrets.PROD_DATABASE_URL }}
run: ./deploy.sh