Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 5 MCQsContinuous Integration (CI) with GitHub Actions
Which event keyword is used to allow a workflow to be triggered manually from the GitHub UI?
Not quite. Try another option.
Answer: workflow_dispatch
The workflow_dispatch event allows users to manually trigger a GitHub Actions workflow directly from the Actions tab in GitHub.
Question 6 of 60 · Jobs & matrix strategies · Easy
What is a matrix strategy used for in GitHub Actions?
Not quite. Try another option.
Answer: To run tests across multiple combinations of operating systems or programming language versions simultaneously
A matrix strategy lets you use variables in a single job definition to automatically create multiple job runs that are based on the combinations of the variables.
Question 7 of 60 · Steps & shell commands · Easy
Which keyword is used inside a workflow step to execute a shell command?
Not quite. Try another option.
Answer: run:
The run keyword tells the job to execute a command on the runner's operating system shell.
Question 8 of 60 · Using marketplace actions · Easy
Where can developers browse and find pre-built actions created by the community?
Not quite. Try another option.
Answer: GitHub Marketplace
The GitHub Marketplace is a central hub where developers can find, share, and use pre-built actions in their workflows.
Question 9 of 60 · Language-specific actions · Easy
Which widely used action sets up a Node.js environment in a workflow?
Not quite. Try another option.
Answer: actions/setup-node
actions/setup-node is an official GitHub action used to download and configure a specific version of Node.js for a job.
Question 10 of 60 · Using caching for faster builds · Easy
Why is caching used in GitHub Actions workflows?
Not quite. Try another option.
Answer: To speed up workflow execution times by reusing dependencies
Caching allows workflows to save and reuse previously downloaded dependencies (like node_modules or .m2), significantly speeding up the build process.
Question 11 of 60 · Multi-job workflows · Easy
By default, how do multiple jobs in a single GitHub Actions workflow execute?
Not quite. Try another option.
Answer: In parallel (simultaneously)
Unless dependencies are explicitly defined using the needs keyword, multiple jobs in a GitHub Actions workflow run in parallel.
Question 12 of 60 · Runners: GitHub-hosted runners · Easy
What is a GitHub-hosted runner?
Not quite. Try another option.
Answer: A virtual machine managed, maintained, and updated by GitHub
GitHub-hosted runners are fresh, pre-configured virtual environments managed by GitHub that run your workflows and are discarded after use.
Question 13 of 60 · Runners:Self-hosted runners · Easy
What is a primary advantage of using a self-hosted runner over a GitHub-hosted runner?
Not quite. Try another option.
Answer: It provides full control over the hardware, operating system, and software tools
Self-hosted runners allow organizations to use their own customized hardware and environments, which is useful for highly specific software requirements or restricted network access.
Why is it generally considered unsafe to use self-hosted runners on public repositories?
Not quite. Try another option.
Answer: Because malicious pull requests could execute harmful code on your infrastructure
If a public repository uses a self-hosted runner, anyone can submit a pull request containing malicious workflow code that will run directly on the host's private infrastructure.
Question 15 of 60 · Docker & GitHub Actions: Building Docker images in CI · Easy
Which shell command is typically executed in a workflow step to build a Docker image?
Not quite. Try another option.
Answer: docker build
The docker build command is used to read a Dockerfile and compile it into a Docker image during the CI process.
Question 16 of 60 · Pushing to Docker Hub · Easy
What must be configured in GitHub before an Action can successfully push a new image to Docker Hub?
Not quite. Try another option.
Answer: Authentication credentials stored securely as GitHub Secrets
To push an image to Docker Hub, the workflow must authenticate using docker login, which requires passing Docker credentials securely stored in GitHub Secrets.
Question 17 of 60 · Pushing to GitHub Container Registry (GHCR) · Easy
What domain name is used to access the GitHub Container Registry (GHCR)?
Not quite. Try another option.
Answer: ghcr.io
GitHub Container Registry is hosted at ghcr.io, which is the domain used to push and pull container images.
Question 18 of 60 · Events, triggers · Easy
In GitHub Actions, what defines an 'event'?
Not quite. Try another option.
Answer: A specific activity or occurrence in the repository that triggers a workflow
An event is a specific activity (like a push, a pull request creation, or an issue opening) that kicks off the execution of a workflow.
Question 19 of 60 · Deploying to servers/cloud using Actions · Easy
How should sensitive information like cloud API keys and deployment passwords be managed in GitHub Actions?
Not quite. Try another option.
Answer: Saved securely as encrypted GitHub Secrets
GitHub Secrets allows you to store sensitive information securely. Workflows can access them without exposing the values in the code or logs.
Which trigger uses POSIX cron syntax to run a workflow at specific times?
Not quite. Try another option.
Answer: schedule
The schedule event allows you to trigger a workflow at a scheduled time using POSIX cron syntax (e.g., 0 0 * * * for daily).
Question 21 of 60 · Events, triggers, workflow directory structure · Medium
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?
Not quite. Try another option.
Answer: .github/workflows/
GitHub Actions automatically discovers and runs workflows that are defined in YAML files located strictly in the .github/workflows/ directory of the repository.
Question 22 of 60 · Workflow triggers: push, pull request, schedule, manual workflow · Medium
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?
Not quite. Try another option.
Answer: workflow_dispatch
The workflow_dispatch event allows you to manually trigger a workflow run. You can also configure it to accept input parameters directly from the GitHub UI.
Question 23 of 60 · Jobs & matrix strategies · Medium
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?
Not quite. Try another option.
Answer: 6
A matrix strategy creates a job execution for every possible combination of the provided variables. With 3 Node versions and 2 operating systems, it results in parallel job executions.
Question 24 of 60 · Multi-job workflows · Medium
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?
Not quite. Try another option.
Answer: needs
By default, jobs in GitHub Actions run in parallel. The needs keyword is used to require that one job must complete successfully before another job can begin.
Question 25 of 60 · Using caching for faster builds · Medium
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?
Not quite. Try another option.
Answer: key
The key input is mandatory. It acts as a unique identifier for the cache. If the key changes (often by hashing a lockfile like package-lock.json), a new cache is generated.
Question 26 of 60 · Steps & shell commands · Medium
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?
Not quite. Try another option.
Answer: run: |
In YAML, the pipe character | denotes a literal block scalar, which preserves line breaks. This allows you to write multi-line bash or shell scripts under the run key.
Question 27 of 60 · Using marketplace actions · Medium
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?
Not quite. Try another option.
Answer: By appending @<commit-SHA> to the action name
To ensure maximum stability and security, pinning an action to a specific commit SHA (e.g., actions/checkout@a1b2c3d4) prevents unexpected changes if the maintainer alters a previously published tag.
Question 28 of 60 · Runners:Self-hosted runners · Medium
What is a primary reason a DevOps team might choose to deploy a self-hosted runner instead of using a GitHub-hosted runner?
Not quite. Try another option.
Answer: To access resources securely inside a private corporate network or VPC
Self-hosted runners are deployed on the user's infrastructure, allowing workflows to securely access internal resources like databases or private registries that are not exposed to the public internet.
Question 29 of 60 · Runners: GitHub-hosted runners · Medium
Which of the following accurately describes the environment of a standard GitHub-hosted runner for Ubuntu?
Not quite. Try another option.
Answer: It is a fresh virtual machine for each job execution that is discarded after the job completes.
GitHub-hosted runners provide a clean, ephemeral virtual machine for each job. Once the job concludes, the virtual machine is immediately decommissioned.
Question 30 of 60 · Runner security & management · Medium
Why is it considered a severe security risk to attach a self-hosted runner to a public repository without specific safeguards?
Not quite. Try another option.
Answer: Because malicious users can submit pull requests that execute untrusted code directly on your local infrastructure.
Workflows triggered by pull requests from forks can execute arbitrary code on the self-hosted runner, potentially compromising the host machine and internal network.
Question 31 of 60 · Docker & GitHub Actions: Building Docker images in CI · Medium
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?
Not quite. Try another option.
Answer: docker/setup-buildx-action
docker/setup-buildx-action sets up a Docker builder instance using Buildx, which is required to leverage features like caching and building images for multiple CPU architectures.
Question 32 of 60 · Pushing to GitHub Container Registry (GHCR) · Medium
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?
Not quite. Try another option.
Answer: ${{ secrets.GITHUB_TOKEN }}
The GITHUB_TOKEN is automatically generated for every workflow run and provides the necessary permissions to authenticate against GHCR without needing a separate personal access token.
Question 33 of 60 · Deploying to servers/cloud using Actions · Medium
How should a DevOps engineer securely pass static cloud provider credentials (like AWS Access Keys) into a GitHub Actions deployment workflow?
Not quite. Try another option.
Answer: Store them as encrypted Repository Secrets and reference them using ${{ secrets.SECRET_NAME }}
Repository Secrets securely encrypt sensitive information. They are never exposed in logs and can be injected safely into the workflow using the ${{ secrets.SECRET_NAME }} context.
Question 34 of 60 · Key components: jobs, steps, actions, runners · Medium
In the GitHub Actions hierarchy, what is the correct relationship between jobs, steps, and workflows?
Not quite. Try another option.
Answer: A workflow contains one or more jobs; a job contains one or more steps.
The structural hierarchy in GitHub Actions begins with a workflow, which defines one or more jobs. Each job executes on a runner and consists of multiple steps, which can either run scripts or standalone actions.
Question 35 of 60 · Pushing to Docker Hub · Medium
Before using docker/build-push-action to push an image to Docker Hub, which step must be executed in the workflow?
Not quite. Try another option.
Answer: Authenticate using docker/login-action with Docker Hub credentials.
To push an image to a private or public registry like Docker Hub, the runner must first be authenticated. This is typically done using the docker/login-action along with Docker Hub credentials stored in GitHub Secrets.
Question 36 of 60 · Language-specific actions · Medium
When configuring a CI workflow for a Python application, what is the primary purpose of using the actions/setup-python action?
Not quite. Try another option.
Answer: It installs a specific version of Python and adds it to the system PATH.
The actions/setup-python action prepares the runner environment by downloading, installing, and caching specific versions of Python, and adding them to the PATH for subsequent steps to use.
Question 37 of 60 · Workflow triggers: push, pull request, schedule, manual workflow · Medium
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?
Not quite. Try another option.
Answer: cron: '0 0 * * *'
In standard POSIX cron syntax, 0 0 * * * translates to minute 0, hour 0 (midnight UTC), every day of the month, every month, and every day of the week.
Question 38 of 60 · Deployments to servers/clouds · Medium
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?
Not quite. Try another option.
Answer: OIDC uses short-lived, dynamically requested tokens, eliminating the need to store static AWS credentials in GitHub Secrets.
OIDC (OpenID Connect) improves security by establishing trust between GitHub and AWS, allowing workflows to request temporary, short-lived access tokens without storing permanent AWS Access Keys.
Question 39 of 60 · Key components: workflows · Medium
If you define environment variables at the root level of a workflow using the env: keyword, what is the scope of those variables?
Not quite. Try another option.
Answer: They are available to all jobs and steps within the workflow.
Defining env variables at the top-level (root) of the workflow YAML makes them globally accessible to every job and step within that specific workflow.
Question 40 of 60 · Understanding workflow automation · Medium
Which of the following best describes the core purpose of a Continuous Integration (CI) workflow in GitHub Actions?
Not quite. Try another option.
Answer: To automatically build, test, and validate code changes whenever a commit is pushed to a repository.
Continuous Integration (CI) focuses on frequently merging code changes into a central repository, where automated builds and tests are run to detect bugs and ensure code quality.
Question 41 of 60 · Jobs & matrix strategies · Hard
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?
Not quite. Try another option.
Answer: They are immediately canceled; use fail-fast: false under the strategy key to allow them to complete.
By default, GitHub Actions matrix strategies evaluate fail-fast as true, meaning if any job in the matrix fails, all other currently running jobs in that matrix are canceled. Setting fail-fast: false forces all jobs to run to completion regardless of individual failures.
Question 42 of 60 · Workflow triggers: push, pull request, schedule, manual workflow · Hard
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?
Not quite. Try another option.
Answer: on: push: branches: [main] paths-ignore: ['docs/**']
GitHub Actions allows specifying either paths or paths-ignore for a single event, but not both simultaneously. Using paths-ignore directly excludes changes that occur exclusively in the targeted directory.
Question 43 of 60 · Using caching for faster builds · Hard
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?
Not quite. Try another option.
Answer: The partial match is restored, and at the end of the job, the updated cache is saved under the new exact key.
If the exact key misses, GitHub searches the restore-keys sequentially. If a partial match is found, it restores that cache. Upon job completion, a new cache is generated and saved using the primary exact key.
Question 44 of 60 · Runner security & management · Hard
Why is it considered a severe security risk to use persistent self-hosted runners for public repositories that accept pull requests from forks?
Not quite. Try another option.
Answer: Forks can trigger workflows that execute arbitrary code, potentially compromising the runner's host environment and persisting malicious payloads for subsequent runs.
Public forks can modify workflow files or build scripts to execute malicious code. On a persistent self-hosted runner, this code could alter the host OS, steal credentials, or leave backdoors that affect future workflow runs from trusted maintainers.
Question 45 of 60 · Pushing to GitHub Container Registry (GHCR) · Hard
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?
Not quite. Try another option.
Answer: packages: write
The GitHub Container Registry is managed under GitHub Packages. To allow the GITHUB_TOKEN to push images, the workflow or job must explicitly grant packages: write permissions.
Question 46 of 60 · Deploying to servers/cloud using Actions · Hard
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?
Not quite. Try another option.
Answer: The job execution is paused and does not consume runner minutes; it waits up to 30 days for approval before being automatically canceled.
When an environment requires manual approval, the workflow run pauses before allocating a runner to the job. Consequently, it does not consume billable runner minutes. If left unapproved, it automatically expires after 30 days.
Question 47 of 60 · Multi-job workflows · Hard
Job A generates a dynamic version string and needs to pass it to Job B. How is this correctly achieved in GitHub Actions?
Not quite. Try another option.
Answer: In Job A, echo the string to $GITHUB_OUTPUT and map it in the job's outputs. In Job B, set needs: Job A and reference it via ${{ needs.JobA.outputs.version }}.
To share data between discrete jobs, Job A must set an output parameter using $GITHUB_OUTPUT and declare it in the job-level outputs block. Job B must declare needs: Job A and access the value through the needs context.
Question 48 of 60 · Deployments to servers/clouds · Hard
When configuring a workflow to deploy to AWS without storing long-lived IAM user credentials as GitHub Secrets, which mechanism should be utilized?
Not quite. Try another option.
Answer: OpenID Connect (OIDC) to exchange a short-lived GitHub Actions token for an AWS role assumption.
OIDC allows GitHub Actions to act as an Identity Provider (IdP). AWS trusts the GitHub token, allowing the workflow to assume an IAM role dynamically, negating the need for long-lived static credentials.
Question 49 of 60 · Steps & shell commands · Hard
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?
Not quite. Try another option.
Answer: Execution halts immediately because GitHub Actions runs bash with set -e and pipefail by default, and the step fails.
By default, GitHub Actions configures the bash shell to run with set -e -o pipefail. This ensures that if any command fails (including those within pipelines), the shell script exits immediately and marks the step as failed.
Question 50 of 60 · Events, triggers, workflow directory structure · Hard
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?
Not quite. Try another option.
Answer: Workflows must be placed in the .github/workflows/ directory to be detected and triggered by GitHub.
GitHub Actions strictly requires workflow definition files to reside in the .github/workflows/ directory. Files placed in other directories, such as .github/actions/, are treated as regular files or custom composite actions, not workflows.
Question 51 of 60 · Docker & GitHub Actions: Building Docker images in CI · Hard
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?
Not quite. Try another option.
Answer: cache-from: type=gha and cache-to: type=gha
The type=gha (GitHub Actions) cache backend directly interfaces with the GitHub Actions Cache API, allowing Docker layers to be pushed to and pulled from the workflow's native cache without requiring an external container registry.
Question 52 of 60 · Runners: GitHub-hosted runners · Hard
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?
Not quite. Try another option.
Answer: Standard GitHub-hosted runners do not have static IP addresses, making strict IP whitelisting highly impractical.
GitHub-hosted runners pull their IP addresses from dynamic, frequently changing Azure IP ranges. Because the exact IP is unpredictable, firewall whitelisting requires whitelisting entire Azure data centers, which is poor security practice.
Question 53 of 60 · Events, triggers, workflow directory structure · Hard
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?
Not quite. Try another option.
Answer: on: workflow_run: workflows: ["Workflow A"] types: [completed]
The workflow_run event is designed to execute a workflow based on the lifecycle of another workflow. Configuring it with types: [completed] and an explicit workflow name allows Workflow B to trigger post-Workflow A.
Question 54 of 60 · Workflow triggers: push, pull request, schedule, manual workflow · Hard
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?
Not quite. Try another option.
Answer: The merge commit of the source and target branch is checked out, and the target repository's secrets are used (excluding pull_request_target).
By default, the pull_request event checks out a simulated merge commit (refs/pull/ID/merge) representing what the code would look like if merged into the base branch. It uses the base (target) repository's secrets, though access to certain privileged tokens is restricted for security.
Question 55 of 60 · Language-specific actions · Hard
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?
Not quite. Try another option.
Answer: Add cache: 'npm' to the with inputs of the setup-node step.
The actions/setup-node action has built-in caching support. Passing cache: 'npm' instructs the action to automatically look for a package-lock.json and generate a cache key to store/restore dependencies efficiently.
Question 56 of 60 · Using marketplace actions · Hard
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?
Not quite. Try another option.
Answer: Referencing the action by its full 40-character Git commit SHA.
Tags and branches are mutable and can be forcefully updated by the author or an attacker who compromises the repository. Pinning an action to its full Git commit SHA ensures the code executed is immutable and exactly what was originally audited.
Question 57 of 60 · Pushing to Docker Hub · Hard
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?
Not quite. Try another option.
Answer: PATs allow fine-grained access control, are easily revocable, and bypass 2FA requirements which otherwise block automated CI pipelines.
If a Docker Hub account has Two-Factor Authentication (2FA) enabled, standard passwords cannot be used for CLI or programmatic login. PATs bypass the interactive 2FA prompt, making them mandatory for CI/CD pipelines while providing the added benefit of being revocable.
Question 58 of 60 · Workflow triggers: push, pull request, schedule, manual workflow · Hard
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?
Not quite. Try another option.
Answer: Use an input with type: choice and provide the options in the options array.
For manual triggers (workflow_dispatch), creating a dropdown menu in the GitHub UI is achieved by setting the input type to choice and defining an array of strings under the options key.
Question 59 of 60 · Runners:Self-hosted runners · Hard
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?
Not quite. Try another option.
Answer: Assign a custom label (e.g., gpu-enabled) to the specific runner, and configure the job with runs-on: [self-hosted, gpu-enabled].
Self-hosted runners can be assigned custom labels during configuration. By providing an array of labels to runs-on, GitHub Actions ensures the job is only dispatched to a runner matching all the specified labels.
Question 60 of 60 · Deploying to servers/cloud using Actions · Hard
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?
Not quite. Try another option.
Answer: Use the concurrency key at the workflow level, defining a group name and setting cancel-in-progress: true.
The concurrency configuration allows developers to limit concurrent runs based on a concurrency group name. Setting cancel-in-progress: true guarantees that when a newer deployment is triggered, the old pending or running deployment is aborted, preventing race conditions.
That's unit 5
Answer a few questions and your score shows up here.
Nearly through. Did unit 5 of INT332 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 5 of INT332 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.