All Microsoft exams
Free GH-200 practice test: 30 questions with answers
30 original questions for GitHub Actions, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 100 questions
All 30 GH-200 questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Ecosystem and deployment (8 questions)
Question 1
A team wants to deploy a web app to Azure from a workflow using a service that has an official action. Which practice is most appropriate?
- AWrite a custom script that copies passwords and store them in a plain text file
- BDeploy by manually uploading files each time through the web portal
- CSkip authentication to save time so the deploy job runs faster
- DUse the official Azure login and deployment actions with OIDC credentials
Show answer and explanationHide answer
Correct answer: DOfficial Azure actions with OIDC give secure, maintained deployment with short-lived credentials. Custom password scripts, manual uploads and skipped authentication are weaker or unsafe.
Question 2
A release must be deployed to production only after it has been tested in a staging environment, and the production job should show the deployment history. Which feature provides this?
- ANo deployment tracking, so release records exist in the CI console output
- BEnvironments with a deployment history and sequential jobs that depend on staging
- CA workflow that deploys both environments at the same moment without waiting for staging to pass
- DManual copying of files between servers using scp from a developer laptop with no audit record
Show answer and explanationHide answer
Correct answer: BEnvironments track deployment history and sequential jobs enforce order. Simultaneous deploys skip gating, manual copies are untracked, and no tracking removes visibility.
Question 3
A team wants to publish a container image to GitHub Container Registry from a workflow, using the built-in token. Which permission must be granted?
- Aissues: write
- Bpackages: write
- Cpages: write only
- Dcontents: read only
Show answer and explanationHide answer
Correct answer: BPublishing packages requires the packages write permission. Read-only contents, Pages and issues permissions do not allow publishing images.
Question 4
A workflow runs a long-running job that sometimes hangs. The team wants the job to fail automatically after a reasonable limit. Which setting should be used?
- Atimeout-minutes at the job level
- BA larger runner with more RAM
- Ccontinue-on-error on every single step
- DA cron schedule that restarts the job
Show answer and explanationHide answer
Correct answer: Atimeout-minutes stops a job after a defined limit. continue-on-error ignores failures, a larger runner may not fix hangs, and cron schedules start runs.
Question 5
Which TWO statements about GitHub Actions usage limits and runners are accurate? (Choose two.)
- AHosted runners and self-hosted runners can both run jobs in a workflow
- BConcurrency settings can help control parallel runs and costs
- CSelf-hosted runners are unavailable for private repositories
- DHosted runners never have usage limits
- ESelf-hosted runners remove all billing considerations
Show answer and explanationHide answer
Correct answer: A, EHosted and self-hosted runners can both run jobs, and concurrency helps manage parallel usage. Self-hosted runners still have infrastructure costs, they are available for private repositories, and hosted usage has limits.
Question 6
A release process must generate a changelog from merged pull requests and attach build artifacts to a GitHub release. Which feature supports this?
- AA manually edited text file on a laptop that is copied by hand into the release and attached through the web interface
- BAttaching artifacts only in a commit message by encoding the files as base64 text inside the message body
- CDeleting releases automatically after each run to keep the release list tidy
- DRelease creation through the API or an action, with generated release notes and asset uploads
Show answer and explanationHide answer
Correct answer: DReleases can be created with generated notes and assets through the API or actions. Manual files, deletion and commit messages do not produce proper release assets.
Question 7
A team wants to deploy a static site to GitHub Pages from a workflow. Which permission and action are required?
- Aactions: admin, administration: write, and contents: write
- Bpages: write and id-token: write with the Pages deployment action
- Cpackages: read only for the container registry image pulls, with contents: read
- Dissues: write only, plus pull-requests: write to label and triage items
Show answer and explanationHide answer
Correct answer: BDeploying to Pages requires pages and id-token permissions along with the Pages deployment action. Issues, packages and admin permissions are not needed.
Question 8
A deployment environment must have a wait timer before production deploys begin, so that the team can cancel if needed. Which feature provides this?
- AEnvironment protection rules with a wait timer
- BAn unrestricted concurrency group for deployments
- CA cron schedule on production that runs each night
- DA sleep command in every step to pause before each deploy
Show answer and explanationHide answer
Correct answer: AEnvironment protection rules support wait timers that delay deployments and allow cancellation. Cron schedules start runs, sleep commands waste resources, and unrestricted concurrency does not add a wait.
Security and secrets (8 questions)
Question 9
A workflow needs an API token for a deployment. The token must not appear in logs or in the workflow file. Which approach is correct?
- AStore it as an encrypted repository or environment secret and reference it through the secrets context
- BCommit it to a file named token.txt in the repository root and read it back with a cat command
- CPaste it into the workflow description field of the pull request template so everyone can see it
- DPrint it at the start of the job for debugging and echo it to the console log unredacted
Show answer and explanationHide answer
Correct answer: AEncrypted secrets referenced through the secrets context are masked in logs and kept out of source. Printing, committing and pasting expose the value.
Question 10
A deployment job must run only after an approval from a designated reviewer, and it must use secrets that only production deployments can access. Which feature supports both?
- ASharing secrets through a public gist in plain text form
- BA repository README note that lists the required reviewers and secret names
- CA workflow with no environment block, so the deploy job runs on every push
- DEnvironments with required reviewers and environment-scoped secrets
Show answer and explanationHide answer
Correct answer: DEnvironments provide protection rules such as required reviewers and scoped secrets. A README note has no enforcement, and public gists expose secrets.
Question 11
A team wants to minimize the permissions of the GITHUB_TOKEN used by a workflow. Which setting should be applied?
- AGrant write-all permissions to avoid authentication errors in every job step
- BRemove the token entirely and disable the checkout steps
- CSet the permissions key to read-only or to only the scopes needed
- DReplace it with an admin personal access token for CI runs
Show answer and explanationHide answer
Correct answer: CExplicit least-privilege permissions limit what the GITHUB_TOKEN can do. Write-all and admin tokens expand risk, and the token is required for many actions.
Question 12
A workflow uses a third-party action. The security team wants to reduce the risk of the action being changed maliciously. Which practice is most effective?
- APin the action to a full commit SHA rather than a mutable tag
- BUse the latest tag without review and let it update automatically
- CDownload the action from a random website via an unverified ZIP file
- DDisable third-party actions in the repository Actions settings page
Show answer and explanationHide answer
Correct answer: APinning to a commit SHA prevents silent changes when tags move. Mutable tags can be retargeted, random downloads are unsafe, and disabling all actions removes needed automation.
Question 13
A pull request from a fork triggers a workflow that needs access to secrets. The team wants to protect these secrets from untrusted code. Which trigger is safer to use?
- Apull_request, which does not expose repository secrets to forks by default
- Bpush to a fork's default branch, which runs workflows with the fork owner's secrets
- Cpull_request_target with checkout of the fork's code and secrets
- Dworkflow_dispatch with secrets printed to the job log in plain text
Show answer and explanationHide answer
Correct answer: AThe pull_request trigger does not give fork PRs access to repository secrets by default. pull_request_target with checkout of untrusted code is a well-known risk, and printing secrets is unsafe.
Question 14
A company wants to allow a workflow to access a cloud provider without storing long-lived credentials in GitHub. Which approach is recommended?
- AOpenID Connect federation so the workflow receives short-lived cloud credentials
- BStoring a root password in a secret kept in the repository settings and reused by workflows
- CWriting credentials in the workflow file encrypted with base64 and rotated by hand twice a year
- DSharing a single access key with every team across several repositories and deployment environments
Show answer and explanationHide answer
Correct answer: AOpenID Connect issues short-lived tokens to workflows, avoiding stored long-lived credentials. Root passwords, shared keys and base64 encoding are insecure.
Question 15
Which TWO practices reduce the risk of exposing secrets in GitHub Actions logs? (Choose two.)
- AUse secrets as part of file names in artifacts
- BAvoid printing secret values or derived data in run steps
- CPass secrets through environment variables only where needed
- DStore secrets in workflow comments
- EEcho secrets to verify that they are set
Show answer and explanationHide answer
Correct answer: B, CAvoiding printed secrets and passing them only where needed limits exposure. Echoing, comments and artifact file names all risk leaking secret values.
Question 16
A repository contains a secret that was accidentally committed to a branch. Which action should be taken first?
- ARevoke and rotate the secret immediately, then remove it from history if needed
- BDelete the branch and assume the secret is gone because the commit is no longer visible
- CEmail the secret to the security team in plain text so it can be reviewed and archived for later
- DWait for the next scheduled review cycle of the security policy before rotating credentials
Show answer and explanationHide answer
Correct answer: AA committed secret must be treated as compromised, so revoking and rotating it comes first. Deleting a branch does not remove history from forks or caches, emailing the secret spreads it, and waiting leaves exposure open.
Automation and runners (7 questions)
Question 17
A workflow must run a build on a machine with a specific internal toolchain that GitHub-hosted runners do not provide. Which option should be used?
- AA GitHub-hosted runner that is renamed to match the internal toolchain labels in the workflow file
- BRunning the build on a developer laptop manually and uploading the final output
- CA self-hosted runner registered to the repository or organization with the required tools
- DRemoving the build step from the workflow so the job just checks out source code
Show answer and explanationHide answer
Correct answer: CSelf-hosted runners let teams run jobs on their own machines with custom tools. Renaming a hosted runner changes nothing, manual laptop builds are not automation, and removing the step fails the requirement.
Question 18
A self-hosted runner is used for public repositories. Which security concern should the team address first?
- AThe length of the runner's name and its registration label settings
- BUntrusted pull requests from forks could run code on the runner
- CThe runner's operating system colour theme and desktop wallpaper settings
- DThe number of branches and open pull requests in the main repository
Show answer and explanationHide answer
Correct answer: BSelf-hosted runners in public repositories can run code from untrusted forks, which risks compromise. Cosmetic and count factors are irrelevant.
Question 19
A team needs a job to use a Docker container image as its execution environment. Which keyword should be used at the job level?
- Acontainer
- Bservices only
- Cuses
- Don
Show answer and explanationHide answer
Correct answer: AThe container keyword sets the image a job runs in. Services run supporting containers alongside the job, uses calls actions, and on defines triggers.
Question 20
A workflow step caches downloaded dependencies to speed up future runs. Which action manages this caching?
- AA copy of the dependencies listed in the README file at the top
- BDownloading the same packages via npm on every run without a key
- CA secret that stores the package list in an encrypted form for runners
- Dactions/cache with a key based on the dependency lock file
Show answer and explanationHide answer
Correct answer: Dactions/cache saves and restores paths using a key, often a hash of the lock file, so the cache updates when dependencies change. Other options do not provide reliable caching.
Question 21
A team wants to upload build outputs from one job so that a deployment job can download them. Which actions are designed for this?
- Aactions/checkout twice with a fetch-depth of 0
- Bactions/cache with no key input for the job
- Cactions/upload-artifact and actions/download-artifact
- Dactions/setup-node and actions/setup-python
Show answer and explanationHide answer
Correct answer: CUpload and download artifact actions share files between jobs in a workflow run. Cache is for reusable dependencies, checkout fetches source, and setup actions install tools.
Question 22
Which THREE are advantages of using reusable workflows and composite actions? (Choose three.)
- ALess duplicated YAML across repositories
- BGuaranteed zero failures
- CAutomatic removal of all security checks
- DCentral maintenance of shared logic
- EConsistent steps across teams
Show answer and explanationHide answer
Correct answer: A, D, EReusable workflows and composite actions reduce duplication, centralize maintenance and standardize steps. They do not remove security checks or guarantee zero failures.
Question 23
A workflow must run a job on macOS and also needs a particular Xcode version. Which approach sets the version on a hosted macOS runner?
- ASet the cron schedule to a later time so the macOS image is ready before the job starts
- BInstall Xcode from a random download link on every run without checksum or signature checks
- CSelect an available runner image and run a step that selects the Xcode version
- DChange the repository name so the workflow is re-provisioned under a new repository URL
Show answer and explanationHide answer
Correct answer: CHosted macOS images include multiple Xcode versions, and a step can select the one needed. Random downloads are slow and unsafe, and renaming or scheduling does not change the toolchain.
Workflow fundamentals (7 questions)
Question 24
A team wants a GitHub Actions workflow to run tests on every push to any branch and on pull requests targeting main. Which trigger configuration is correct?
- Aon: workflow_call, so tests run when another workflow calls this file with inputs
- Bon: release published, so tests run after a version tag is pushed to remote
- Con: schedule with cron '*/5 * * * *', so tests run every five minutes on a timer
- Don: push for all branches and pull_request with branches set to main
Show answer and explanationHide answer
Correct answer: DThe push trigger runs on pushes and the pull_request trigger with a branch filter runs for PRs targeting main. Schedule, workflow_call and release triggers do not match the requirement.
Question 25
In a workflow file, a developer wants two jobs to run in parallel, with a third job running only after both succeed. Which keyword controls this ordering?
- Aenv
- Bneeds
- Cruns-on
- Duses
Show answer and explanationHide answer
Correct answer: BThe needs keyword defines job dependencies, so a job waits for listed jobs to finish successfully. runs-on selects the runner, uses calls an action or reusable workflow, and env sets variables.
Question 26
A workflow step must run only if the previous steps in the job failed, to send a notification. Which expression should be used on that step?
- Aif: success()
- Bif: always() only for cancellation
- Cif: failure()
- Druns-on: failure
Show answer and explanationHide answer
Correct answer: CThe failure() status function runs the step when a previous step failed. success() is the default, always() runs regardless, and runs-on is not a conditional.
Question 27
A team wants to reuse an entire build process across several repositories. Which feature should they create?
- AA copy of the same YAML pasted into every repository
- BA repository secret holding build steps
- CA personal access token with repo access
- DA reusable workflow called with workflow_call
Show answer and explanationHide answer
Correct answer: DA reusable workflow with workflow_call can be called from other workflows and repositories, which avoids duplication. Copying YAML creates drift, and tokens and secrets are not reuse mechanisms.
Question 28
A job needs values shared between steps within the same job, such as a computed version string. How should a step pass this value to later steps?
- AStore it in the repository README file under the docs section and parse it in later steps
- BWrite the value to the GITHUB_ENV file, or to GITHUB_OUTPUT for job outputs
- CSave it in the runner's temporary folder with no reference path
- DPrint it as a YAML comment in the workflow file so reviewers can read it
Show answer and explanationHide answer
Correct answer: BWriting to GITHUB_ENV makes a value available to later steps as an environment variable, and GITHUB_OUTPUT exposes step outputs. Comments and READMEs are not runtime channels.
Question 29
A developer wants to avoid running the same workflow twice when a branch is updated quickly, so that only the latest run continues. Which feature should be used?
- AA larger runner with more CPU cores and memory for the job
- BA timeout-minutes value of one minute on each job so hung runs stop early
- Cconcurrency with a group key and cancel-in-progress set to true
- DA cron schedule that starts the workflow every hour again
Show answer and explanationHide answer
Correct answer: CThe concurrency setting with cancel-in-progress cancels older runs in the same group. Timeouts stop long jobs, schedules start runs, and larger runners do not prevent duplicate runs.
Question 30
Which TWO are valid ways to limit when a workflow runs? (Choose two.)
- ARemoving the on key entirely
- BSetting timeout to zero
- CPath filters on push and pull_request triggers
- DBranch filters on triggers
- ERunning on every commit to every fork regardless of settings
Show answer and explanationHide answer
Correct answer: C, DPath and branch filters limit triggers to relevant changes. Removing the on key stops triggers entirely, and a zero timeout does not restrict runs.