Where must you place a GitHub Actions workflow file?
In the repository’s .github/workflows/ directory, named with a .yml (or .yaml) extension.
What top‐level YAML keys are required in a basic workflow?
name, on, and jobs.
Why is the key called name:?
Because it’s a human‐readable label for the workflow shown in the Actions UI.
What does the on: key represent?
The events (e.g., push, pull_request, schedule) that trigger the workflow.
How do you restrict a workflow to run only on pushes to specific branches?
Under on: → push: add branches: with a list (e.g., - main, - ‘feat/**’).
What key do you use to ignore certain file paths from triggering a workflow?
paths-ignore: under the event (e.g., push:).
What does the jobs: section define?
A mapping of one or more isolated “jobs,” each running on its own runner.
How do you name a job, and what are the rules?
Use a YAML key under jobs: (e.g., test-and-build:). It must be unique, without spaces, typically kebab‐case or snake_case.
What does runs-on: specify for a job?
Which runner image to use (e.g., ubuntu-latest, windows-latest, macos-latest, or self-hosted).
Name four common GitHub‐hosted runner labels.
ubuntu-latest, ubuntu-22.04, windows-latest, macos-latest.
What is the purpose of the steps: list in a job?
It defines the ordered actions (or shell commands) to execute on that job’s runner.
In a step, what’s the difference between uses: and run:?
uses: invokes a reusable Action (from Marketplace or local), while run: executes a shell command directly.
What does actions/checkout@v4 do?
Clones (checks out) your repository’s code into the runner, so subsequent steps can access it.
What’s the role of actions/setup-node@v4?
Installs a specified Node.js version (e.g., node-version: ‘18’) and can enable package caching (e.g., cache: ‘npm’).
Why would you use actions/cache@v3?
To save and restore directories (e.g., node_modules, .nuxt/.cache) between workflow runs, speeding up builds.
How do you configure actions/cache to cache node_modules?
How do you run a shell command in a step?
Use - name: … followed by run: your-command (e.g., run: npm ci). Optionally specify shell: if not using the default.
What are “contexts” in GitHub Actions?
Built‐in objects (e.g., github, env, runner) that provide data about the workflow run, branch name, commit SHA, etc.
How do you use an expression to reference a context value?
Wrap it in ${{ }} (e.g., ${{ github.ref }}, ${{ secrets.MY_SECRET }}).
How do you set an environment variable only for a single step?
What is the if: key used for in a step?
To conditionally run or skip that step based on an expression (e.g., if: success() && github.ref == ‘refs/heads/main’).
How do you grant a step permission to write logs or check out private submodules?
Use uses: actions/checkout@v4 with persist-credentials: true (default) or set permissions: at the workflow or job level.
What does a “matrix strategy” accomplish?
Runs the same job multiple times with different configurations (e.g., Node versions or OS) in parallel.
How do you define a matrix to run tests on Node16, 18, and 20?
strategy:
matrix:
node-version: [16, 18, 20]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: ‘npm’
# …