Unit 5 - Practice Quiz
1 What is the primary purpose of workflow automation in GitHub Actions?
2 In which directory must GitHub Actions workflow files be stored to be recognized by GitHub?
/src/workflows
/github/actions
.github/workflows
.actions/config
3 What file format is used to define GitHub Actions workflows?
4 Which GitHub Actions component provides the virtual server environment where jobs are executed?
5 Which event keyword is used to allow a workflow to be triggered manually from the GitHub UI?
workflow_dispatch
manual_run
schedule
push
6 What is a matrix strategy used for in GitHub Actions?
7 Which keyword is used inside a workflow step to execute a shell command?
execute:
cmd:
run:
shell:
8 Where can developers browse and find pre-built actions created by the community?
9 Which widely used action sets up a Node.js environment in a workflow?
actions/run-node
actions/js-env
actions/install-npm
actions/setup-node
10 Why is caching used in GitHub Actions workflows?
11 By default, how do multiple jobs in a single GitHub Actions workflow execute?
12 What is a GitHub-hosted runner?
13 What is a primary advantage of using a self-hosted runner over a GitHub-hosted runner?
14 Why is it generally considered unsafe to use self-hosted runners on public repositories?
15 Which shell command is typically executed in a workflow step to build a Docker image?
docker push
docker build
docker pull
docker start
16 What must be configured in GitHub before an Action can successfully push a new image to Docker Hub?
17 What domain name is used to access the GitHub Container Registry (GHCR)?
docker.github.com
hub.github.com
registry.github.io
ghcr.io
18 In GitHub Actions, what defines an 'event'?
19 How should sensitive information like cloud API keys and deployment passwords be managed in GitHub Actions?
passwords.txt
20 Which trigger uses POSIX cron syntax to run a workflow at specific times?
schedule
timer
cron_run
clock
21 To ensure GitHub recognizes a YAML file as an Actions workflow, in which specific directory path relative to the repository root must it be placed?
.github/actions/
.github/workflows/
workflows/
.actions/workflows/
22 Which event trigger should you configure in a GitHub Actions workflow to allow users to manually trigger the workflow from the GitHub Actions tab, optionally providing input parameters?
push
manual_run
workflow_dispatch
repository_dispatch
23
You need to test your Node.js application against Node versions 14, 16, and 18 on both ubuntu-latest and windows-latest. How many total job executions will a standard matrix strategy create for this configuration?
24 In a multi-job workflow, Job B requires the output or successful completion of Job A before it can start. Which keyword is used in the configuration for Job B to enforce this dependency?
requires
needs
after
depends_on
25
When using the actions/cache action to speed up builds by caching dependencies, which input parameter is mandatory to accurately determine if the cache needs to be invalidated or restored?
hashFiles
restore-keys
key
path
26
If you want to execute a multi-line shell script within a single step in a GitHub Actions workflow, how should you format the run keyword in the YAML file?
run: |
execute: -
run: >
script:
27 When referencing a third-party action from the GitHub Marketplace in your workflow, how do you pin the action to a specific immutable release to prevent breaking changes?
release: keyword under the action
:<version-number> to the action name
version: keyword under the action
@<commit-SHA> to the action name
28 What is a primary reason a DevOps team might choose to deploy a self-hosted runner instead of using a GitHub-hosted runner?
29 Which of the following accurately describes the environment of a standard GitHub-hosted runner for Ubuntu?
30 Why is it considered a severe security risk to attach a self-hosted runner to a public repository without specific safeguards?
31 When building a Docker image using GitHub Actions, which action is standardly used to set up Docker Buildx, allowing for advanced features like multi-platform builds?
docker/setup-buildx-action
docker/build-push-action
actions/docker-build
docker/login-action
32 When authenticating a workflow to push a Docker image to the GitHub Container Registry (GHCR), which credential is automatically provided by GitHub Actions and recommended for use?
${{ secrets.GITHUB_TOKEN }}
${{ env.GHCR_TOKEN }}
${{ github.personal_access_token }}
${{ secrets.DOCKER_PASSWORD }}
33 How should a DevOps engineer securely pass static cloud provider credentials (like AWS Access Keys) into a GitHub Actions deployment workflow?
.env file and commit it to the repository
workflow_dispatch trigger
${{ secrets.SECRET_NAME }}
34 In the GitHub Actions hierarchy, what is the correct relationship between jobs, steps, and workflows?
35
Before using docker/build-push-action to push an image to Docker Hub, which step must be executed in the workflow?
docker/login-action with Docker Hub credentials.
36
When configuring a CI workflow for a Python application, what is the primary purpose of using the actions/setup-python action?
black.
pytest test suite automatically.
37
You want to run a workflow every day at midnight UTC using the schedule event. What is the correct cron syntax to define this trigger?
cron: '0 0 * * *'
cron: '0 0 0 * *'
cron: '0 * * * *'
cron: '* 0 * * *'
38 When deploying an application to an AWS server using GitHub Actions via OIDC (OpenID Connect), what is the main advantage over using long-lived IAM user credentials?
39
If you define environment variables at the root level of a workflow using the env: keyword, what is the scope of those variables?
40 Which of the following best describes the core purpose of a Continuous Integration (CI) workflow in GitHub Actions?
41 A developer configures a build matrix with 3 operating systems and 3 Node.js versions (9 jobs total). Job 2 fails after 30 seconds. What is the default behavior of the remaining running jobs in the matrix, and how can it be altered to allow independent completion?
fail-fast: false under the strategy key to allow them to complete.
auto-resume: true to continue.
ignore-errors: true under the matrix key to allow them to complete.
continue-on-error: false to cancel them.
42
You want a workflow to trigger on pushes to the main branch, EXCEPT when the changes are strictly within the docs/ directory. Which of the following YAML configurations achieves this without throwing a syntax or validation error?
on: push: branches: [main] paths-ignore: ['docs/**']
on: push: branches: [main] ignore-paths: ['docs/']
on: push: branches: [main] paths: ['**'] paths-ignore: ['docs/**']
on: push: branches: [main] exclude: paths: ['docs/**']
43
When using the actions/cache action, what happens if there is a cache miss for the exact key, but a partial match exists in the restore-keys list?
key.
44 Why is it considered a severe security risk to use persistent self-hosted runners for public repositories that accept pull requests from forks?
45
To successfully authenticate and push a Docker image to the GitHub Container Registry (ghcr.io) within a GitHub Actions workflow using the default GITHUB_TOKEN, which specific permission must be explicitly granted to the job?
packages: write
docker: push
contents: write
registry: write
46
A workflow contains a deployment job configured with environment: production. The production environment in GitHub is set to require a manual reviewer. What happens to the workflow execution while waiting for the reviewer's approval?
47 Job A generates a dynamic version string and needs to pass it to Job B. How is this correctly achieved in GitHub Actions?
runs-on context of Job B.
{{ needs.JobA.outputs.version }}.
actions/download-artifact to read it directly into a job-level variable.
{{ env.VERSION }}.
48 When configuring a workflow to deploy to AWS without storing long-lived IAM user credentials as GitHub Secrets, which mechanism should be utilized?
49 In a bash shell step on an Ubuntu runner, what is the default behavior if a command within a multi-line script fails (returns a non-zero exit code) halfway through the step?
set -e and pipefail by default, and the step fails.
exit 1 is explicitly called at the end of the script.
50
A developer places a valid workflow file at .github/actions/deploy.yml. Upon pushing to the repository, the workflow does not trigger. What is the root cause?
.github/workflows/ directory to be detected and triggered by GitHub.
.yaml, as .yml is only supported for composite actions.
main.yml to be recognized as a workflow.
51
When building Docker images in CI, optimizing build times is crucial. Using the docker/build-push-action, which caching strategy natively utilizes GitHub Actions' built-in Cache API to store and retrieve Docker layers?
cache-from: type=gha and cache-to: type=gha
cache-from: type=actions and cache-to: type=actions
cache-from: type=local and cache-to: type=local
cache-from: type=registry and cache-to: type=registry
52 You are deploying an application from a GitHub-hosted runner to a corporate database that strictly requires IP whitelisting. Which statement accurately describes the limitation of standard GitHub-hosted runners in this scenario?
53 A team wants Workflow B to automatically execute only after Workflow A has successfully completed, regardless of whether Workflow A was triggered via a push, schedule, or manual event. Which event trigger should be configured in Workflow B?
on: after_workflow: name: ["Workflow A"]
on: [workflow_call]
on: workflow_run: workflows: ["Workflow A"] types: [completed]
on: repository_dispatch: types: [Workflow A_success]
54
When a workflow is triggered by a pull_request event originating from a fork repository, which repository's commit and secrets are used for the workflow execution by default?
pull_request_target).
55
In a Node.js workflow using actions/setup-node@v3, how can you configure the action to automatically cache npm dependencies by analyzing the lockfile, thereby bypassing the need for a manual actions/cache step?
cache: 'npm' to the with inputs of the setup-node step.
setup-node action caches dependencies by default; no configuration is required.
auto-cache: true under the strategy matrix definition.
npm-cache: true as an environment variable in the job level.
56 To mitigate supply chain attacks when utilizing third-party actions from the GitHub Marketplace, what is the most secure method for referencing an action in a workflow file?
@v2).
main or master branch.
57
When configuring automated pushes to Docker Hub using the docker/login-action in a CI pipeline, why is it functionally critical and recommended to use Docker Personal Access Tokens (PATs) instead of the main account password?
58
You are defining a manual workflow using workflow_dispatch. You need to allow the user to select an environment (either dev, staging, or prod) from a dropdown menu. How is this defined in the workflow YAML?
type: dropdown and provide the options as a comma-separated string.
type: choice and provide the options in the options array.
type: string and provide a regex validation rule pattern: dev|staging|prod.
59 A team manages multiple self-hosted runners across different architectures and specialized hardware (e.g., GPUs). How can a specific workflow job strictly and explicitly target a self-hosted runner equipped with a GPU?
REQUIRE_GPU=true to the job context, which the runner's polling mechanism will filter by.
runs-on: self-hosted-gpu and GitHub will automatically detect the hardware capabilities.
gpu-enabled) to the specific runner, and configure the job with runs-on: [self-hosted, gpu-enabled].
60
You have a deployment workflow triggered on every push to the main branch. If multiple developers merge PRs in rapid succession, you want to ensure only one deployment runs at a time and any pending deployments are canceled in favor of the latest push. Which configuration achieves this?
max-parallel: 1 at the job level.
concurrency key at the workflow level, defining a group name and setting cancel-in-progress: true.
timeout-minutes key to forcefully fail older jobs if a newer job enters the queue.
queue: true and strategy: override in the deployment job configuration.