# Free GH-200 practice questions

> 10 free GH-200 practice questions with the correct answer and an explanation.

Page: https://devopscodelab.com/exams/github-gh-200/free-practice-questions/
Practice exams: https://devopscodelab.com/exams/github-gh-200/

### Question 1 of 10

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?

- A. if: ${{ !failure() && !cancelled() && needs.test.result == 'success' }}
- B. if: ${{ needs.docs.result == 'skipped' || needs.docs.result == 'success' }}
- C. if: ${{ success() && needs.test.result == 'success' }}
- D. if: ${{ always() }}

**Answer:** A

**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

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?

- A. Append the value to GITHUB_PATH in the build job so the deploy job finds it on its search path
- B. Move the echo command into a workflow-level env: block so every job in the workflow inherits the VERSION value
- C. Write the value to GITHUB_STATE in the build job so that the runner shares it with every downstream job
- D. Write the value to GITHUB_OUTPUT in a step with an id, expose it as a build job output, and read needs.build.outputs

**Answer:** D

**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

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?

- A. postgres on port 5432, using the service label as the hostname
- B. The service container IP address read from the runner context
- C. host.docker.internal on port 5432 through the Docker bridge
- D. localhost on port 5432

**Answer:** D

**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

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?

- A. One run for the push to feature/login and one run for the pull_request event, because both triggers apply
- B. Only a push run, because opening a pull request does not create a new commit
- C. One run triggered by the pull_request event, and none for the push to feature/login
- D. Two pull_request runs, one for the opened activity and one for synchronize

**Answer:** C

**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

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?

- A. timeout-minutes lowered on the job so the hang produces an error
- B. ACTIONS_RUNNER_DEBUG set to true as a secret or variable
- C. ACTIONS_STEP_DEBUG set to true as a repository secret or variable
- D. continue-on-error set to true on the first step of the hanging job

**Answer:** B

**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

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

- A. Keep USER appuser and set WORKDIR /github/workspace in the Dockerfile so that the user owns the folder
- B. Remove the USER instruction so the action runs as the default root user, which can access GITHUB_WORKSPACE
- C. Keep USER appuser and ask consumers to run chmod -R 777 on the workspace before calling the action
- D. Keep USER appuser and add a pre-entrypoint script that recreates the workspace as an empty directory

**Answer:** B

**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

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?

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

**Answer:** B

**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

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?

- A. Require approval for all outside collaborators to run workflows, and disable forking of private and internal repositories
- B. Set workflow permissions to read and write, and add a branch protection rule requiring two approvals on main in every repository
- C. Set default workflow permissions to read-only, and leave Allow GitHub Actions to create and approve pull requests cleared
- D. Set workflow permissions to read repository contents and packages, and add pull-requests: none to every workflow file in each repository

**Answer:** C

**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

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?

- A. Disable GitHub Actions for the organization and let each repository opt back in once its actions are reviewed
- B. Allow enterprise actions and reusable workflows only, and fork every needed third-party action into an internal repository that the team keeps updated
- C. Allow all actions and reusable workflows, and rely on a CODEOWNERS rule for .github/workflows to review each new action
- D. Allow enterprise, and select non-enterprise, actions and reusable workflows, with GitHub-created and verified-creator actions enabled

**Answer:** D

**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

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?

- A. Generate an installation token for an organization-owned GitHub App with contents: write and push the tag with it
- B. Grant the GITHUB_TOKEN contents: write and actions: write so that its pushed tags trigger the second workflow
- C. Create a fine-grained personal access token on a shared employee account and store it as a repository secret
- D. Add workflow_run to the second workflow and push the tag with the GITHUB_TOKEN as before from the release job

**Answer:** A

**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.

Ready for a timed run? Take the free 15-question GH-200 mini exam: https://devopscodelab.com/app/exams/github-gh-200/mini/

DevOpsCode Lab is not affiliated with GitHub. GH-200 and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
