GH-200

Free GH-200 practice questions

10 questions from our GH-200 practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.

Back to the GH-200 practice exams

Question 1 of 10, Author and manage workflows

Job publish declares needs: [test, docs]. The docs job is skipped by its own if condition on most runs, and publish is then skipped too, although test succeeded. Which condition on publish makes it run when test succeeds and docs succeeds or is skipped?

  1. Aif: ${{ !failure() && !cancelled() && needs.test.result == 'success' }} Correct answer
  2. Bif: ${{ needs.docs.result == 'skipped' || needs.docs.result == 'success' }}
  3. Cif: ${{ success() && needs.test.result == 'success' }}
  4. Dif: ${{ always() }}

Answer and explanation: A skipped dependency makes the implicit success() check false, so publish needs a status function that is not success(); !failure() && !cancelled() lets it run after a skip while still blocking on failures or cancellation, and the test check enforces the requirement. A condition without a status function gets success() added and is still skipped. success() fails on the skipped docs job, and always() would also run publish after test fails.

Question 2 of 10, Author and manage workflows

In a build job, a step runs echo "VERSION=1.4.2" >> "$GITHUB_ENV". A separate deploy job declared with needs: build references ${{ env.VERSION }} and gets an empty value. What should the team change?

  1. AAppend the value to GITHUB_PATH in the build job so the deploy job finds it on its search path
  2. BMove the echo command into a workflow-level env: block so every job in the workflow inherits the VERSION value
  3. CWrite the value to GITHUB_STATE in the build job so that the runner shares it with every downstream job
  4. DWrite the value to GITHUB_OUTPUT in a step with an id, expose it as a build job output, and read needs.build.outputs Correct answer

Answer and explanation: GITHUB_ENV only affects later steps of the same job, so a value must cross job boundaries through a step output mapped to jobs.build.outputs and read with needs.build.outputs. A workflow-level env block holds static values and cannot run a command. GITHUB_STATE passes values between the pre, main, and post phases of one action, and GITHUB_PATH only prepends directories to PATH for later steps in the same job.

Question 3 of 10, Author and manage workflows

A job runs directly on ubuntu-latest, not inside a container, and defines a postgres service container with ports: ['5432:5432']. Which connection host and port should the integration tests use?

  1. Apostgres on port 5432, using the service label as the hostname
  2. BThe service container IP address read from the runner context
  3. Chost.docker.internal on port 5432 through the Docker bridge
  4. Dlocalhost on port 5432 Correct answer

Answer and explanation: When the job runs directly on the runner machine, service containers are reached through the ports mapped to the host, so localhost:5432 is correct. Using the service label as the hostname works only when the job itself runs in a container on the same Docker network. host.docker.internal is used from inside containers to reach the host, and the runner context does not expose service container IP addresses.

Question 4 of 10, Consume and troubleshoot workflows

A workflow declares on: { push: { branches: [main] }, pull_request: {} }. A developer pushes a new commit to branch feature/login and then opens a pull request from feature/login into main. Which workflow runs start?

  1. AOne run for the push to feature/login and one run for the pull_request event, because both triggers apply
  2. BOnly a push run, because opening a pull request does not create a new commit
  3. COne run triggered by the pull_request event, and none for the push to feature/login Correct answer
  4. DTwo pull_request runs, one for the opened activity and one for synchronize

Answer and explanation: The push trigger is filtered to main, so pushing to feature/login does not start a run, while opening the pull request fires pull_request with the opened activity type. The push run would only appear if the branch filter matched. A pull_request trigger does fire on opened without a new commit, and synchronize only fires when new commits are pushed to the pull request's head branch later.

Question 5 of 10, Consume and troubleshoot workflows

Jobs on a self-hosted runner hang intermittently before the first step starts, and the step logs show nothing useful. The administrator needs the runner process's own diagnostic logs in the downloadable log archive. Which setting should be enabled?

  1. Atimeout-minutes lowered on the job so the hang produces an error
  2. BACTIONS_RUNNER_DEBUG set to true as a secret or variable Correct answer
  3. CACTIONS_STEP_DEBUG set to true as a repository secret or variable
  4. Dcontinue-on-error set to true on the first step of the hanging job

Answer and explanation: ACTIONS_RUNNER_DEBUG adds the runner diagnostic logs to the log archive, which is what is needed for hangs before any step runs. ACTIONS_STEP_DEBUG increases step output but does not include runner process diagnostics. A shorter timeout only turns the hang into a failure without explaining it, and continue-on-error cannot help when the job never reaches its first step.

Question 6 of 10, Author and maintain actions

A Docker container action's Dockerfile adds USER appuser. Consumers report permission errors when the action writes into the workspace. What does GitHub recommend?

  1. AKeep USER appuser and set WORKDIR /github/workspace in the Dockerfile so that the user owns the folder
  2. BRemove the USER instruction so the action runs as the default root user, which can access GITHUB_WORKSPACE Correct answer
  3. CKeep USER appuser and ask consumers to run chmod -R 777 on the workspace before calling the action
  4. DKeep USER appuser and add a pre-entrypoint script that recreates the workspace as an empty directory

Answer and explanation: GitHub documents that Docker actions must run as the default root user and should not use the USER instruction, because otherwise they may not be able to access GITHUB_WORKSPACE. GitHub also advises against setting WORKDIR, because the runner sets the working directory itself. Asking consumers to change permissions is fragile and insecure, and recreating the workspace would discard the checked-out files.

Question 7 of 10, Author and maintain actions

A setup action downloads a compiler archive, extracts it, and should reuse the extracted version on the same runner in later jobs. Which toolkit package is designed for this?

  1. A@actions/artifact, with uploadArtifact and downloadArtifact
  2. B@actions/tool-cache, with downloadTool, extractTar, and cacheDir Correct answer
  3. C@actions/cache, with saveCache and restoreCache keyed per job and runner OS
  4. D@actions/io, with mkdirP, cp, and which for file operations

Answer and explanation: @actions/tool-cache downloads and extracts tools and stores them in the runner's tool cache so later jobs on that runner can find them. @actions/cache uses the remote Actions cache service, which suits dependencies rather than toolchain installs in the tool cache. Artifacts are for sharing outputs between jobs, and @actions/io only provides file system helpers.

Question 8 of 10, Manage GitHub Actions for the enterprise

An organization wants new workflows to receive a read-only GITHUB_TOKEN by default and to prevent workflows from approving their own pull requests. Which organization settings achieve this?

  1. ARequire approval for all outside collaborators to run workflows, and disable forking of private and internal repositories
  2. BSet workflow permissions to read and write, and add a branch protection rule requiring two approvals on main in every repository
  3. CSet default workflow permissions to read-only, and leave Allow GitHub Actions to create and approve pull requests cleared Correct answer
  4. DSet workflow permissions to read repository contents and packages, and add pull-requests: none to every workflow file in each repository

Answer and explanation: The organization's default workflow permissions setting controls the GITHUB_TOKEN default, and the separate create-and-approve option controls whether workflows can approve pull requests. Read and write defaults violate the first requirement, and branch rules do not change token defaults. Editing every workflow does not scale, and outside-collaborator approval and fork settings address different risks.

Question 9 of 10, Manage GitHub Actions for the enterprise

An organization wants workflows to use only actions from its own enterprise, actions created by GitHub, and Marketplace actions from verified creators. Which Actions policy setting meets this requirement with the LEAST manual upkeep?

  1. ADisable GitHub Actions for the organization and let each repository opt back in once its actions are reviewed
  2. BAllow enterprise actions and reusable workflows only, and fork every needed third-party action into an internal repository that the team keeps updated
  3. CAllow all actions and reusable workflows, and rely on a CODEOWNERS rule for .github/workflows to review each new action
  4. DAllow enterprise, and select non-enterprise, actions and reusable workflows, with GitHub-created and verified-creator actions enabled Correct answer

Answer and explanation: The select-actions policy lets the organization combine its enterprise actions with GitHub-created and verified-creator actions without listing each one. Allowing all actions does not restrict anything, and code review alone does not stop unapproved actions from running. Forking every third-party action creates ongoing maintenance, and disabling Actions blocks all automation.

Question 10 of 10, Secure and optimize automation

A release workflow must push a tag that triggers a second workflow in the same repository. The GITHUB_TOKEN does not trigger it, and the security team forbids personal access tokens tied to employees. What is the BEST approach?

  1. AGenerate an installation token for an organization-owned GitHub App with contents: write and push the tag with it Correct answer
  2. BGrant the GITHUB_TOKEN contents: write and actions: write so that its pushed tags trigger the second workflow
  3. CCreate a fine-grained personal access token on a shared employee account and store it as a repository secret
  4. DAdd workflow_run to the second workflow and push the tag with the GITHUB_TOKEN as before from the release job

Answer and explanation: Events created with a GitHub App installation token do trigger workflows, and the app is owned by the organization rather than a person, with scoped and short-lived tokens. Extra GITHUB_TOKEN permissions do not change the rule that its events do not start new runs. A shared-account PAT is still a personal token, and workflow_run reacts to workflow completion rather than to a tag push, which changes the trigger semantics.