GitHub Actions Beginner Quiz
30 questions on GitHub Actions.
Question 1: What is GitHub Actions?
- A. A social network for developers
- B. A CI/CD platform that allows you to automate your build, test, and deployment pipeline directly within GitHub β (correct answer)
- C. A tool for designing websites
- D. A database management system
Explanation: GitHub Actions brings automation directly into your repository, removing the need to set up external CI servers like Jenkins.
Question 2: Which file format is used to write GitHub Actions workflows?
- A. JSON
- B. XML
- C. YAML β (correct answer)
- D. HTML
Explanation: YAML is a human-readable data serialization language. It relies on strict indentation (spaces) to define structure.
Question 3: In which specific directory must you place your workflow YAML files for GitHub Actions to discover and run them?
- A.
.github/workflows/ β (correct answer)
- B.
/actions/
- C.
/.workflows/
- D.
/src/github/
Explanation: If your YAML file is placed anywhere else, GitHub will ignore it.
Question 4: What is a "Workflow" in GitHub Actions?
- A. A single terminal command
- B. A configurable automated process that will run one or more jobs β (correct answer)
- C. A user role
- D. A branch protection rule
Explanation: A workflow is defined by a YAML file. You can have multiple workflows in a single repository (e.g., one for testing, one for deploying).
Question 5: What does the on keyword do in a workflow file?
- A. Turns the server on
- B. Defines the trigger(s) that will cause the workflow to run β (correct answer)
- C. Connects to the database
- D. Logs the user in
Explanation: For example, on: push means the workflow will trigger every time someone pushes code to the repository.
Question 6: How do you trigger a workflow ONLY when a Pull Request is opened or updated?
- A.
on: pull_request β (correct answer)
- B.
trigger: pr
- C.
when: pull_request
- D.
run: PR
Explanation: This is the most common trigger in open-source projects, ensuring tests run before code is merged.
Question 7: What is a "Job" in GitHub Actions?
- A. A paid subscription
- B. A set of steps in a workflow that execute on the same runner β (correct answer)
- C. A database backup
- D. A GitHub repository
Explanation: By default, multiple jobs in a workflow run in parallel. A job consists of a sequence of steps.
Question 8: What does the runs-on keyword define?
- A. The time of day the workflow runs
- B. The type of virtual machine (Runner) that will execute the job β (correct answer)
- C. The repository name
- D. The branch name
Explanation: runs-on: ubuntu-latest tells GitHub to spin up a fresh Ubuntu Linux virtual machine to run your job.
Question 9: What is a "Runner"?
- A. An automated bot that replies to comments
- B. A server that runs your workflows when they're triggered β (correct answer)
- C. A fast downloading tool
- D. A testing framework
Explanation: GitHub provides hosted runners (Ubuntu, Windows, macOS), or you can host your own (Self-hosted runners) on your own infrastructure.
Question 10: What is a "Step" in a GitHub Actions job?
- A. A new YAML file
- B. An individual task that can run commands or an action β (correct answer)
- C. A repository
- D. A runner
Explanation: Steps are executed in order, one after another, on the same runner, allowing them to share data.
Question 11: How do you execute a simple shell command inside a step?
- A.
execute: npm test
- B.
bash: npm test
- C.
run: npm test β (correct answer)
- D.
cmd: npm test
Explanation: The run keyword tells the runner to execute the string as a command in the terminal.
Question 12: What is an "Action" in GitHub Actions?
- A. A pre-packaged, reusable set of commands that can be used in a step β (correct answer)
- B. A movie
- C. A server reboot
- D. A database transaction
Explanation: Instead of writing 20 shell commands to configure Node.js, you can simply use the actions/setup-node Action from the marketplace.
Question 13: Which keyword is used to call/use an Action within a step?
- A.
run
- B.
uses β (correct answer)
- C.
action
- D.
call
Explanation: Example: uses: actions/checkout@v3. This tells the step to fetch the code for that specific Action.
Question 14: What does the actions/checkout action do?
- A. Pays for a subscription
- B. Checks out your repository under
$GITHUB_WORKSPACE, so your workflow can access it β (correct answer)
- C. Logs out of GitHub
- D. Checks for errors
Explanation: Almost every workflow starts with actions/checkout. Without it, the runner's hard drive is completely empty.
Question 15: What is the GitHub Actions Marketplace?
- A. A place to buy physical servers
- B. A central location where you can find, share, and use Actions created by the GitHub community β (correct answer)
- C. A store to buy domain names
- D. A place to hire developers
Explanation: There are thousands of Actions available for deploying to AWS, sending Slack messages, running security scans, etc.
Question 16: How do you define environment variables for a specific step?
- A.
env: { KEY: VALUE } β (correct answer)
- B.
vars: KEY=VALUE
- C.
set: KEY VALUE
- D.
export: KEY=VALUE
Explanation: The env keyword allows you to set environment variables that the shell commands in your step can access.
Question 17: How do you securely pass a password or API key to a workflow without exposing it in the code?
- A. Base64 encode it in the YAML
- B. Store it in GitHub Secrets and access it using
${{ secrets.MY_PASSWORD }} β (correct answer)
- C. Write it in a hidden file
- D. Send it via email
Explanation: Secrets are encrypted environment variables created in the Repository Settings. They are never printed in the logs.
Question 18: What does the needs keyword do?
- A. Tells GitHub what software is required
- B. Defines dependencies between jobs, ensuring one job finishes before another starts β (correct answer)
- C. Asks for user input
- D. Requests more CPU power
Explanation: If Job B has needs: build, Job B will wait for the build job to complete successfully before starting.
Question 19: What happens if Job A fails, and Job B has needs: Job A?
- A. Job B runs anyway
- B. Job B is skipped β (correct answer)
- C. Job B waits for you to fix Job A
- D. Job B runs but ignores errors
Explanation: By default, if a dependency fails, all subsequent dependent jobs are cancelled/skipped to save time and compute resources.
Question 20: How can you trigger a workflow on a schedule (e.g., every day at midnight)?
- A.
on: time
- B.
on: schedule using cron syntax β (correct answer)
- C.
trigger: daily
- D.
run: midnight
Explanation: Example: on: schedule: - cron: '0 0 * * *'. This is useful for nightly database backups or security scans.
Question 21: How do you manually trigger a workflow from the GitHub UI?
- A.
on: manual
- B.
on: click
- C.
on: workflow_dispatch β (correct answer)
- D.
on: push_button
Explanation: Adding workflow_dispatch to the on section adds a "Run workflow" button in the Actions tab of your repository.
Question 22: What is a "Matrix Build"?
- A. A build that runs in the Matrix
- B. A strategy that lets you use variables to automatically create multiple job runs that are based on the combinations of the variables β (correct answer)
- C. A 3D graph of the build
- D. A complex mathematical formula
Explanation: If you want to test your code on Node.js versions 14, 16, and 18, you use a matrix. GitHub will automatically spawn three parallel jobs.
Question 23: How do you access the matrix variable in your steps?
- A.
$matrix.version
- B.
${{ matrix.version }} β (correct answer)
- C.
%matrix.version%
- D.
!matrix.version!
Explanation: The ${{ }} syntax is the GitHub Actions expression syntax used to evaluate variables dynamically during execution.
Question 24: What does the if conditional do in a step?
- A. Creates a loop
- B. Prevents the step from running unless a specific condition is met β (correct answer)
- C. Reboots the server if there is an error
- D. Checks for syntax errors
Explanation: Example: if: github.ref == 'refs/heads/main' ensures a deployment step only runs if the code is on the main branch.
Question 25: What is an "Artifact" in GitHub Actions?
- A. An old repository
- B. A file or collection of files produced during a workflow run (like a compiled binary) that you can download or pass to another job β (correct answer)
- C. A deleted branch
- D. A bug in the code
Explanation: You use the actions/upload-artifact action to save these files before the runner is destroyed at the end of the job.
Question 26: What is GITHUB_TOKEN?
- A. A physical USB security key
- B. An automatically generated secret token provided by GitHub to authenticate on behalf of the GitHub App installed on your repository β (correct answer)
- C. A cryptocurrency
- D. A coupon code for GitHub Pro
Explanation: You can use ${{ secrets.GITHUB_TOKEN }} to allow your workflow to do things like leave a comment on a Pull Request automatically.
Question 27: How can you pass data (like a URL) from Job A to Job B?
- A. Save it to a text file
- B. Use Job Outputs and the
needs context β (correct answer)
- C. Send an email
- D. You cannot pass data between jobs
Explanation: Job A must declare an outputs block. Job B (which needs: Job A) can then read it using ${{ needs.job_a.outputs.url }}.
Question 28: What does continue-on-error: true do?
- A. Ignores all errors in the entire repository
- B. Allows a workflow run to continue even if that specific step or job fails β (correct answer)
- C. Suppresses warning messages
- D. Automatically fixes code errors
Explanation: This is useful for experimental tests. If the experimental test fails, it won't crash the entire deployment pipeline.
Question 29: What is a "Reusable Workflow"?
- A. A workflow you copy and paste
- B. A workflow that is designed to be called by other workflows, promoting DRY (Don't Repeat Yourself) principles β (correct answer)
- C. A workflow that runs infinitely
- D. A template repository
Explanation: Instead of writing the deployment logic in 50 repositories, you can write it once and use on: workflow_call to let other repos use it.
Question 30: What is GitHub Environments?
- A. The physical server room for GitHub
- B. A feature that allows you to configure protection rules (like manual approval) and environment-specific secrets for deployments (e.g., Staging vs. Production) β (correct answer)
- C. A virtual reality app
- D. A code editor
Explanation: If a job targets the "Production" environment, GitHub can automatically pause the workflow and wait for a manager to click "Approve" before continuing.