Microsoft GitHub Actions GH-200 Dumps in PDF

Free Microsoft GH-200 Real Questions (page: 2)

HOTSPOT (Drag and Drop is not supported)
You have a GitHub repository named Repo1. Repo1 uses GitHub Actions workflows that upload build artifacts.
You plan to change the artifact and log retention period to 30 days.
You need to remove expired GitHub Actions artifacts from Repo1. The solution must explicitly identify and delete existing expired artifacts by using the REST API.
How should you complete the script? To answer, select the appropriate options in the answer area.
Note: Each correct selection is worth one point.
Hot Area:

  1. See Explanation section for answer.

Answer(s): A

Explanation:



Box 1: GET
GET retrieves the list of GitHub Actions artifacts without modifying them.
Box 2: "/repos/$OWNER/$REPO/actions/artifacts"


/repos/$OWNER/$REPO/actions/artifacts is the GitHub REST API endpoint for listing artifacts in a specific repository.
The jq expression filters artifacts where expired == true, and the subsequent DELETE requests target their IDs.



For which type of GitHub Actions workflows should you use a self-hosted runner?

  1. workflows on a wide range of open-source software preinstalled in a GitHub-hosted environment
  2. workflows in environments that have specific hardware or operating system requirements that are unavailable on a GitHub-hosted runner
  3. workflows that require high availability and automatic scaling
  4. workflows that have standard configurations and frequent GitHub updates

Answer(s): B

Explanation:

Self-hosted runners are primarily used for workflows that require specialized hardware, private network access, custom software configurations, or strict cost and security controls.
While technically any standard GitHub Actions workflow can target a self-hosted runner, organizations deploy them to handle specific scenarios where standard GitHub-hosted runners fall short.
Workflows Requiring Private Network Access
Internal Deployments: Workflows deploying code to internal servers, private databases, or environments tucked safely behind a corporate firewall.
On-Premises Testing: Verification jobs that must interact with physical laboratory equipment or locally hosted APIs.
VPN-Protected Infrastructure: Pipelines needing direct, secure access to private subnets inside AWS, Azure, Google Cloud, or local data centers without exposing ports to the public internet.
Workflows with Custom Software & OS Requirements
Legacy System Builds: Automation requiring specialized operating systems, unique kernel versions, or specific distributions not offered by GitHub.
Proprietary Tooling: Workflows that depend on expensive licensed commercial software, massive SDKs, or pre-configured local caching engines.
Persistent Cache Pipelines: Large-scale builds (like heavy C++ or Android compilations) that benefit significantly from a persistent file system to avoid re-downloading gigabytes of dependencies for every single run.
High-Performance & Custom Hardware Workflows
Machine Learning Pipelines: Training workflows that demand dedicated, high-end physical GPUs.
Large Compute Jobs: Resource-heavy builds requiring vast amounts of RAM, multiple CPU cores, or high disk I/O beyond what standard virtual cloud instances provide.


Reference:

https://docs.github.com/actions/hosting-your-own-runners



As a developer, you are using a Docker container action in your workflow.
What is required for the action to run successfully?

  1. The job env must be set to a Linux environment.
  2. The action must be published to the GitHub Marketplace.
  3. The referenced action must be hosted on Docker Hub.
  4. The job runs-on must specify a Linux machine with Docker installed.

Answer(s): D

Explanation:

To run a Docker container action, the job's runs-on environment must be a Linux machine that has Docker installed.
Key Requirements
Linux OS Only: Docker container actions are only supported on Linux runners. They cannot run on Windows or macOS runners.
Docker Installed: The runner must have the Docker CLI and daemon installed and running to build and execute the action's container.
GitHub-Hosted Runners: If you use GitHub-hosted runners, you must specify an Ubuntu environment (e.g., runs-on: ubuntu-latest), as these come pre-configured with Docker.
Self-Hosted Runners: For self-hosted runners, you must manually ensure the machine is running Linux and has Docker installed.


Reference:

https://docs.github.com/actions/sharing-automations/creating-actions/creating-a-docker-container-action



As a developer, you need to add the correct syntax to allow the following workflow file to be triggered by multiple types of events.
Which two code blocks should you add starting at line 5? (Each correct answer presents a complete solution. Choose two.)

  1. on: [push, pull_request]
  2. on:
    branches:
    - 'main'
    - 'dev'
  3. on:
    schedule:
    - cron: '*/15 * * * *'
    initiate:
    - 'main'
  4. on: [push, commit]
  5. on:
    push:
    branches:
    - main release:
    types:
    - created
  6. on:
    env:
    - 'prod'
    - 'qa'
    - 'test'

Answer(s): A,E



You need to trigger a workflow using the GitHub API for activity that happens outside of GitHub.
Which workflow event do you use?

  1. workflow_run
  2. deployment
  3. check_suite
  4. repository_dispatch

Answer(s): D

Explanation:

You can use the GitHub API to trigger a webhook event called repository_dispatch when you want to trigger a workflow for activity that happens outside of GitHub .


Reference:

https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows



You are a DevOps engineer working on a custom action. You want to conditionally run a script at the start of the action, before the main entrypoint.
Which code block should be used to define the metadata file for your custom action?

  1. runs:
    using: 'nodel6'
    pre-if: github.event_name == 'push' then 'start.js'
    main: 'index.js'
  2. runs:
    using: 'nodel6'
    pre: 'start.js'
    pre-if: github.event_name == 'push'
    main: 'index.js'
  3. runs:
    using: 'nodel6'
    start: 'start.js'
    start-if: github.event_name == 'push'
    main: 'index.js'
  4. runs:
    using: 'nodel6'
    before: 'start.js'
    before-if: github.event_name == 'push'
    main: 'index.js’

Answer(s): B

Explanation:

The pre: line before the pre-if: line.
Note: runs.pre-if
Optional
Allows you to define conditions for the pre: action execution. The pre: action will only run if the conditions in pre-if are met. If not set, then pre-if defaults to always(). In pre-if, status check functions evaluate against the job's status, not the action's own status.
Note that the step context is unavailable, as no steps have run yet.
In this example, cleanup.js only runs on Linux-based runners:
pre: 'cleanup.js'
pre-if: runner.os == 'linux'


Reference:

https://docs.github.com/en/actions/reference/workflows-and-actions/metadata-syntax



As a developer, one of your workflows will require XCode version 11.2 hosted on macOS Catalina (i.e., v10.15). You’ve already created and configured a self-hosted runner to conform to those requirements and registered it with your organization.
What else should you do to ensure that the workflow accesses the correct runner instance? (Each answer presents a complete solution. Choose three.)

  1. Add your runner to the appropriate runner groups.
  2. In the workflow, specify:
    runs-on: [ ${{groups.macos-10.15}}, ${{groups.xcode-11.2}} ].
  3. Create custom runner labels for macos-10.15 and xcode-11.2.
  4. Create runner groups named macos-10.15 and xcode-11.2.
  5. In the workflow, specify:
    runs-on: [self-hosted, macos-10.15, xcode-11.2].
  6. Assign the custom labels to the self-hosted runner.

Answer(s): C,E,F

Explanation:

[C, F] Using custom labels to route jobs
You can create custom labels and assign them to your self-hosted runners at any time. Custom labels let you send jobs to particular types of self-hosted runners, based on how they're labeled.
[E] Using default labels to route jobs
A self-hosted runner automatically receives certain labels when it is added to GitHub Actions. These are used to indicate its operating system and hardware platform:
self-hosted: Default label applied to self-hosted runners.
linux, windows, or macOS: Applied depending on operating system.
x64, ARM, or ARM64: Applied depending on hardware architecture.
You can use your workflow's YAML to send jobs to a combination of these labels. In this example, a self-hosted runner that matches all three labels will be eligible to run the job:
runs-on: [self-hosted, linux, ARM64]
self-hosted - Run this job on a self-hosted runner.
linux - Only use a Linux-based runner.
ARM64 - Only use a runner based on ARM64 hardware.


Reference:

https://docs.github.com/en/actions/how-tos/manage-runners/self-hosted-runners/use-in-a-workflow



When reviewing an action for use, what file defines its available inputs and outputs?

  1. inputs.yml
  2. defaults.json
  3. workflow.yml
  4. config.json
  5. action.yml

Answer(s): E

Explanation:

A custom GitHub Action's inputs, outputs, and other configurations are defined in its metadata file, which must be named action.yml or action.yaml and placed at the root of the action's repository. This YAML file specifies how the action runs (e.g., using Docker or JavaScript) and provides the metadata for its inputs and outputs, which are then used by workflows that call the action.
Key aspects of the action.yml or action.yaml file
Format: It uses YAML syntax.
Location: It must be in the root directory of your action's repository.
Contents: It defines the action's name, description, inputs, outputs, and the runs configuration to specify the execution environment (like a Docker image or JavaScript file) and entrypoint.
Inputs and Outputs: The file includes inputs and outputs sections to declare the data the action accepts and produces, respectively.


Reference:

https://docs.github.com/en/actions/reference/workflows-and-actions/metadata-syntax



Share your comments for Microsoft GH-200 exam with other users:

A
AI Tutor Explanation
5/10/2026 12:51:57 AM

Which statement is true about using default environment variables? The environment variables can be read in workflows using the ENV: variable_name syntax. The environment variables created should be prefixed with GITHUB_ to ensure they can be accessed in workflows The environment variables can be set in the defaults: sections of the workflow The GITHUB_WORKSPACE environment variable should be used to access files from within the runner.
Correct answer: The statement "The GITHUB_WORKSPACE environment variable should be used to access files from within the runner." is true.
Why the others are false:

  • ENV: variable_name syntax is not how you read env vars in workflows. Use ${{ env.VARIABLE }} in expressions or $VARIABLE in a shell.
  • Environment variables don’t need a GITHUB_ prefix. Custom vars can have any name; GITHUB_ is only for built-in, predefined vars.
  • defaults: cannot set environment variables. It configures defaults for run steps (like shell or working-directory), not env vars.

Extra tip:
  • GITHUB_WORKSPACE (or ${{ github.workspace }}) is the root path on the runner where the repository is checked out. Use it to access files, e.g., $GITHUB_WORKSPACE/... or ${{ github.workspace }}/....

AI Tutor 👋 I’m here to help!