Prepare Top Microsoft GH-200 Exam Study Guide Practice Questions Edition [Q24-Q47]

Share

Prepare Top Microsoft GH-200 Exam Study Guide Practice Questions Edition

Go to GH-200 Questions - Try GH-200 dumps pdf

NEW QUESTION # 24
Which command can you include in your workflow file to set the output parameter for an action?

  • A. echo "::add-mask::$ACTI0N_C0L0R"
  • B. echo "action_color=purple" >> $GITHUB_OUTPUT
  • C. echo "::debug::action_color=purple"
  • D. echo "action_color=purple" >> $GITHUB_ENV

Answer: B

Explanation:
Setting an output parameter
Sets a step's output parameter. Note that the step will need an id to be defined to later retrieve the output value. You can set multi-line output values with the same technique used in the Multiline strings section to define multi-line environment variables.
echo "{name}={value}" >> "$GITHUB_OUTPUT"
Example of setting an output parameter
This example demonstrates how to set the SELECTED_COLOR output parameter and later retrieve it:
- name: Set color
id: color-selector
run: echo "SELECTED_COLOR=green" >> "$GITHUB_OUTPUT"
- name: Get color
env:
SELECTED_COLOR: ${{ steps.color-selector.outputs.SELECTED_COLOR }}
run: echo "The selected color is $SELECTED_COLOR"
Reference:
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands


NEW QUESTION # 25
What menu options in a repository do you need to select in order to use a starter workflow that is provided by your organization?

  • A. Actions > Load workflow
  • B. Workflow > New workflow
  • C. Workflow > Load workflow
  • D. Actions > New workflow

Answer: D

Explanation:
To use a starter workflow provided by your organization, you need to go to the Actions tab in the repository and select New workflow. This option allows you to either create a new workflow or select from a list of available workflow templates, including starter workflows provided by your organization.


NEW QUESTION # 26
As a developer, how can you identify a composite action on GitHub?

  • A. The action's repository includes Dockerfile and package.json files.
  • B. The action's repository includes an init.sh file in the root directory.
  • C. The action.yml metadata file has the runs.using value set to composite.
  • D. The action's repository name includes the keyword "composite."

Answer: C

Explanation:
runs.using for composite actions
Required: You must set this value to 'composite'.
Reference:
https://docs.github.com/en/actions/reference/workflows-and-actions/metadata-syntax


NEW QUESTION # 27
As a developer, your self-hosted runner sometimes looses connection while running jobs. How should you troubleshoot the issue affecting your self-hosted runner?

  • A. Access the self-hosted runner's installation directory and look for log files in the _diag folder.
  • B. Set the DEBUG environment variable to true before starting the self-hosted runner to produce more verbose console output.
  • C. Start the self-hosted runner with the --debug flag to produce more verbose console output.
  • D. Locate the self-hosted runner in your repository's settings page and download its log archive.

Answer: A

Explanation:
When troubleshooting a self-hosted runner, you can access the _diag folder located in the self-hosted runner's installation directory. This folder contains diagnostic logs that can help you identify the root cause of issues, such as connection problems.


NEW QUESTION # 28
As a developer, how can you identify a JavaScript action on GitHub?

  • A. The action.yml metadata file has the runs.using value set to node16.
  • B. The action's repository name includes the keyword "JavaScript."
  • C. The action's repository includes a js.yml file in the .github/workflows directory.
  • D. The action.yml metadata file references a package.json file.

Answer: D

Explanation:
Creating a JavaScript action, example
Prerequisites
Before you begin, you'll need to download Node.js and create a public GitHub repository.
* steps omitted *
From your terminal, initialize the directory with npm to generate a package.json file.
npm init -y
Adding actions toolkit packages
The actions toolkit is a collection of Node.js packages that allow you to quickly build JavaScript actions with more consistency.
When you commit and push your code, your updated repository should look like this:
hello-world-javascript-action/
─ action.yml
─ dist/
─ index.js
─ package.json
─ package-lock.json
─ README.md
─ rollup.config.js
─ src/
─ index.js
Reference:
https://docs.github.com/en/actions/tutorials/create-actions/create-a-javascript-action#creating-an- action-metadata-file


NEW QUESTION # 29
What is the simplest action type to run a shell script?

  • A. Composite action
  • B. Docker container action
  • C. JavaScript action
  • D. Bash script action

Answer: C

Explanation:
Types of actions
Docker container actions. Docker containers package the environment with the GitHub Actions code. ...
JavaScript actions. JavaScript actions can run directly on a runner machine, and separate the action code from the environment used to run the code. ...
Composite Actions.
Note:
JavaScript actions
JavaScript actions can run directly on a runner machine, and separate the action code from the environment used to run the code. Using a JavaScript action simplifies the action code and executes faster than a Docker container action.
Reference:
https://docs.github.com/en/actions/concepts/workflows-and-actions/custom-actions


NEW QUESTION # 30
You need to make a script to retrieve workflow run logs via the API. Which is the correct API to download a workflow run log?

  • A. POST /repos/:owner/:repo/actions/runs/:run_id/logs
  • B. GET /repos/:owner/:repo/actions/artifacts/logs
  • C. GET /repos/:owner/:repo/actions/runs/:run_id/logs
  • D. POST /repos/:owner/:repo/actions/runs/:run_id

Answer: C

Explanation:
The GET /repos/:owner/:repo/actions/runs/:run_id/logs API endpoint is used to retrieve the logs of a specific workflow run identified by run_id. This is the correct method for downloading logs from a workflow run.


NEW QUESTION # 31
How should you print a debug message in your workflow?

  • A. echo "::add-mask::Set variable myVariable to true"
  • B. echo "Set variable MyVariable to true" >> $DEBUG_MESSAGE
  • C. echo "debug_message=Set variable myVariable to true" >> &GITHUB_OUTPUT
  • D. echo "::debug::Set variable myVariable to true"

Answer: D

Explanation:
Example: Setting a debug message
echo "::debug::Set the Octocat variable"
Reference:
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands


NEW QUESTION # 32
Which of the following is the most common way to target a specific major release version?

  • A. steps:
    - uses: actions/checkout@v3
  • B. steps:
    - uses: actions/checkout
  • C. steps:
    - uses: actions/checkout@U1673995124
  • D. steps:
    - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c

Answer: A

Explanation:
Example: Using versioned actions
steps:
# Reference a specific commit
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
*-> # Reference the major version of a release
- uses: actions/checkout@v4
# Reference a specific version
- uses: actions/[email protected]
# Reference a branch
- uses: actions/checkout@main
Reference:
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax


NEW QUESTION # 33
As a developer, your Actions workflow often reuses the same outputs or downloaded dependencies from one run to another. To cache dependencies for a job, you are using the GitHub cache action. Which input parameters are required for this action? (Choose two.)

  • A. key: the key created when saving a cache and the key used to search for a cache
  • B. cache-hit: the copy action key used with restore parameter to restore the data from the cache
  • C. restore-keys: the copy action key used with cache parameter to cache the data
  • D. path: the file path on the runner to cache or restore
  • E. dependency: the name and version of a package to cache or restore
  • F. ref: the ref name of the branch to access and restore a cache created

Answer: A,D

Explanation:
The key is required because it uniquely identifies the cache. It is used to store and retrieve cached data. When creating or restoring a cache, you need to define a key that will be used to identify the cache.
The path is the file path on the runner that you want to cache. This is where the cached files or dependencies are located and should be specified to tell GitHub where to store or retrieve the cache from.


NEW QUESTION # 34
As a developer, you have configured an IP allow list on a GitHub organization. Which effects does the IP allow list have on GitHub Actions? (Each answer presents a complete solution.
Choose two.)

  • A. You can use GitHub-hosted larger runners since they can be configured with static IP addresses.
  • B. You can use standard GitHub-hosted runners since their IP addresses are automatically allowed.
  • C. You must allow GitHub Actions's IP address ranges in order to use marketplace actions.
  • D. You can use self-hosted runners with known IP addresses.

Answer: A,D

Explanation:
Using GitHub Actions with an IP allow list. If you use an IP allow list and would also like to use GitHub Actions, you must use self-hosted runners or GitHub-hosted larger runners with static IP address ranges To allow your self-hosted or larger hosted runners to communicate with GitHub, add the IP address or IP address range of your runners to the IP allow list that you have configured for your enterprise.
Reference:
https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization- secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for- your-organization


NEW QUESTION # 35
As a DevOps engineer, you need to execute a deployment to different environments like development and testing based on the labels added to a pull request. The deployment should use the releases branch and trigger only when there is a change in the files under 'apps' folder. Which code block should be used to define the deployment workflow trigger?

  • A. on:
    pull_request:
    types: [labeled]
    branches:
    - 'releases/**'
    paths:
    - 'apps'
  • B. on:
    pull_request_review:
    types: [labeled]
    branches:
    - 'releases'
    paths:
    - 'apps/**'
  • C. on:
    pull_request_label:
    branches:
    - 'releases'
    paths:
    - 'apps/**'
  • D. on:
    pull_request:
    types: [labeled]
    branches:
    - 'releases'
    paths:
    - 'apps/**'

Answer: D

Explanation:
Incorrect:
[Not A] pull_request activitiy type labeled not specified.
pull_request_label is not a trigger.
[Not B] Specifies branches branches that has a name that starts with releases. We are only interested in the release branch.
branches:
- 'releases/**'
[Not C]
pull_request_review
Runs your workflow when a pull request review is submitted, edited, or dismissed. A pull request review is a group of pull request review comments in addition to a body comment and a state.
Reference:
https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows


NEW QUESTION # 36
In which scenarios could the GITHUB_TOKEN be used? (Each correct answer presents a complete solution. Choose two.)

  • A. to add a member to an organization
  • B. to create a repository secret
  • C. to publish to GitHub Packages
  • D. to create issues in the repo
  • E. to read from the file system on the runner
  • F. to leverage a self-hosted runner

Answer: C,D

Explanation:
[D] To authenticate to a GitHub Packages registry within a GitHub Actions workflow, you can use:
*-> GITHUB_TOKEN to publish packages associated with the workflow repository.
* A personal access token (classic) with at least read:packages scope to install packages associated with other private repositories (GITHUB_TOKEN can be used if the repository is granted read access to the package.
[E] You can use the GITHUB_TOKEN to make authenticated API calls. This example workflow creates an issue using the GitHub REST API:
Reference:
https://docs.github.com/en/packages/learn-github-packages/introduction-to-github-packages
https://docs.github.com/en/actions/tutorials/authenticate-with-github_token


NEW QUESTION # 37
As a developer, you need to make sure that only actions from trusted sources are available for use in your GitHub Enterprise Cloud organization. Which of the following statements are true?
(Each correct answer presents a complete solution. Choose three.)

  • A. GitHub-verified actions can be collectively enabled for use in the enterprise.
  • B. Actions can be published to an internal marketplace.
  • C. Individual third-party actions enabled with a specific tag will prevent updated versions of the action from introducing vulnerabilities.
  • D. Specific actions can individually be enabled for the organization, including version information.
  • E. Actions created by GitHub are automatically enabled and cannot be disabled.
  • F. Actions can be restricted to only those available in the enterprise.

Answer: A,B,D

Explanation:
[A] Internal Actions Marketplace
The reason for having an internal actions marketplace is to have a central location for all the actions that can be used inside our production organization. This is to prevent any actions from the public marketplace from being used in our production organization, without being checked for security risks first.
[B] Allow Marketplace actions by verified creators: You can allow all GitHub Marketplace actions created by verified creators to be used by workflows. When GitHub has verified the creator of the action as a partner organization, the badge is displayed next to the action in GitHub Marketplace.
[C] You can enable specific actions for the organization by identifying them and providing version control, ensuring only trusted versions are used in workflows.
Reference:
https://devopsjournal.io/blog/2021/10/14/GitHub-Actions-Internal-Marketplace
https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-organization- settings/disabling-or-limiting-github-actions-for-your-organization


NEW QUESTION # 38
Which files are required for a Docker container action in addition to the source code? (Each correct answer presents a partial solution. Choose two.)

  • A. action.yml
  • B. Dockerfile
  • C. metadata.yml
  • D. Actionfile

Answer: A,B

Explanation:
Creating a Docker container action
Create a dockerfile
Dockerfile support for GitHub Actions
When creating a Dockerfile for a Docker container action, you should be aware of how some Docker instructions interact with GitHub Actions and an action's metadata file.
Creating an action metadata file
Create a new action.yml file.
Reference:
https://docs.github.com/en/actions/tutorials/use-containerized-services/create-a-docker-container- action
https://docs.github.com/en/actions/reference/workflows-and-actions/dockerfile-support


NEW QUESTION # 39
As a DevOps engineer, you are trying to leverage an organization secret in a repo. The value received in the workflow is not the same as that set in the secret. What is the most likely reason for the difference?

  • A. The Codespace secret doesn't match the expected value.
  • B. The Encrypt Secret setting was not configured for the secret.
  • C. There is a different value specified at the enterprise level.
  • D. There is a different value specified at the rego level.
  • E. There is a different value specified at the workflow level.

Answer: D

Explanation:
GitHub secrets are defined at different levels: organization, repository, and sometimes at the workflow level. If a secret is defined at both the organization level and the repository level, the repository-level secret will take precedence. So, if the value of the secret differs between these levels, the workflow will use the value from the repository level instead of the organization level.


NEW QUESTION # 40
You are reaching your organization's storage limit for GitHub artifacts and packages. What should you do to prevent the storage limit from being reached? (Each correct answer presents a complete solution. Choose two.)

Answer:

Explanation:
B.C
Explanation:
[E] To bypass GitHub's limit of 100 MB you can use Git Large File Storage (Git LFS). It stores references to your file in the repo by creating a pointer file. However, the actual file is going to be stored at a different location.
[C] Configuring the retention period for GitHub Actions artifacts and logs in your organization You can configure the retention period for GitHub Actions artifacts and logs in your organization.
By default, the artifacts and log files generated by workflows are retained for 90 days before they are automatically deleted. You can adjust the retention period, depending on the type of repository:
For public repositories: you can change this retention period to anywhere between 1 day or 90 days.
For private repositories: you can change this retention period to anywhere between 1 day or 400 days.
When you customize the retention period, it only applies to new artifacts and log files, and does not retroactively apply to existing objects. For managed repositories and organizations, the maximum retention period cannot exceed the limit set by the managing organization or enterprise.
Reference:
https://gitprotect.io/blog/github-storage-limits/
https://docs.github.com/en/organizations/managing-organization-settings/configuring-the- retention-period-for-github-actions-artifacts-and-logs-in-your-organization


NEW QUESTION # 41
You are reaching your organization's storage limit for GitHub artifacts and packages. What should you do to prevent the storage limit from being reached? (Choose two.)

  • A. Configure the repo to use Git Large File Storage.
  • B. Delete artifacts from the repositories manually
  • C. Use self-hosted runners for all workflow runs.
  • D. Configure the artifact and log retention period.
  • E. Disable branch protections in the repository.

Answer: B,D

Explanation:
Deleting artifacts from repositories manually will free up storage space. Artifacts are typically stored for a limited time by default, but manual cleanup can help manage space.
Configuring the artifact and log retention period allows you to control how long artifacts and logs are retained in your repository. By shortening the retention period, you can prevent unnecessary accumulation of data and manage storage more effectively.


NEW QUESTION # 42
Which syntax correctly accesses a job output (output1) of an upstream job (job1) from a dependent job within a workflow?

  • A. ${{job1.outputs.output1}}
  • B. ${{needs.job1.outputs.output1}}
  • C. ${{depends.job1.output1}}
  • D. ${{needs.job1.output1}}

Answer: B

Explanation:
To access the outputs in the dependent job, use the needs.<job_id>.outputs.<output_name> syntax. For example, the following job accesses the output1 and output2 outputs defined in job1:
jobs:
# Assume job1 is defined as above
job2:
runs-on: ubuntu-latest
needs: job1
steps:
- env:
OUTPUT1: ${{needs.job1.outputs.output1}}
OUTPUT2: ${{needs.job1.outputs.output2}}
run: echo "$OUTPUT1 $OUTPUT2"
Reference:
https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/pass-job- outputs


NEW QUESTION # 43
Which GitHub Actions event configuration triggers only for pull requests targeting the release branch and not for push events?

  • A. on: pull_request: branches: - release
  • B. on: push: branches: - release
  • C. on: pull_request_target: branches: - release
  • D. on: pull_request: types: - opened

Answer: A

Explanation:
The correct option is on: pull_request: branches: - release. This configuration runs only when a pull request targets the release branch and it does not run on push events.
The pull_request event triggers on pull request activity and the branches filter matches the base branch of the pull request. By specifying the release branch, this configuration limits runs to pull requests that target that branch. Because it listens only for the pull_request event, pushes will not trigger the workflow.


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

  • A. action.yml
  • B. workflow.yml
  • C. inputs.yml
  • D. config.json
  • E. defaults.json

Answer: A

Explanation:
The action.yml file defines the inputs and outputs for a GitHub Action. This file contains metadata about the action, including the required inputs and outputs, as well as other configurations like the action's description, runs, and environment setup.


NEW QUESTION # 45
As a developer, you need to leverage Redis in your workflow. What is the best way to use Redis on a self-hosted Linux runner without affecting future workflow runs?

  • A. Add a run step to your workflow, which dynamically installs and configures Redis as part of your job.
  • B. Install Redis on the hosted runner image and place it in a runner group. Specify label: in your job to target the runner group.
  • C. Set up Redis on a separate machine and reference that instance from your job.
  • D. Specify container: and services: in your job definition to leverage a Redis service container.

Answer: D

Explanation:
Creating Redis service containers
You can use service containers to create a Redis client in your workflow. You can create a Redis service for jobs that run in containers or directly on the runner machine.
Configuring the runner job
The example uses the ubuntu-latest GitHub-hosted runner as the Docker host.
The workflow configures a service container with the label redis.
jobs:
# Label of the runner job
runner-job:
# You must use a Linux environment when using service containers or container jobs runs-on: ubuntu-latest
# Service containers to run with `runner-job`
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
Reference:
https://docs.github.com/en/actions/tutorials/use-containerized-services/create-redis-service- containers


NEW QUESTION # 46
What is the most suitable action type for a custom action written in TypeScript?

  • A. Docker container action
  • B. JavaScript action
  • C. composite run step
  • D. Bash script action

Answer: B

Explanation:
Example: Build your custom GitHub Action
To build your action, run npm run bundle. This will compile the TypeScript code in the src/ directory and output the JavaScript code in the dist/ directory. The exact command for bundle is defined in the package.json file.
Note: About custom actions
Actions are individual tasks that you can combine to create jobs and customize your workflow. Y Types of action You can build Docker container, JavaScript, and composite actions.
Reference:
https://victoronsoftware.com/posts/typescript-github-action/
https://docs.github.com/en/actions/concepts/workflows-and-actions/custom-actions


NEW QUESTION # 47
......


Microsoft GH-200 Exam Syllabus Topics:

TopicDetails
Topic 1
  • Author and Maintain Workflows: This section of the exam measures skills of DevOps Engineers and Automation Specialists and covers building and managing workflows triggered by events such as pushes, scheduled times, manual triggers, and webhooks. It includes understanding workflow components like jobs, steps, actions, and runners, syntax correctness, environment variables, secrets management, and dependencies between jobs. Candidates will also demonstrate practical abilities to create workflows for various purposes, including publishing packages, using service containers, routing jobs, and deploying releases to cloud providers.
Topic 2
  • Consume Workflows: This domain targets Software Developers and Quality Assurance Engineers and focuses on interpreting workflow runs and their outcomes. It covers identifying triggering events, reading workflow configurations, troubleshooting failures by analyzing logs, enabling debug logging, managing environment variables, caching dependencies, and passing data between jobs. Candidates also manage workflow runs, artifacts, approvals, and status badges, as well as locating workflows within repositories and leveraging organizational templated workflows.
Topic 3
  • Author and Maintain Actions: This domain evaluates the abilities of Action Developers and Automation Engineers to select and create suitable types of GitHub Actions, such as JavaScript, Docker containers, or run steps. It emphasizes troubleshooting action code, understanding the components and file structures of actions, and using workflow commands within actions to communicate with runners, including exit code management.
Topic 4
  • Manage GitHub Actions in the Enterprise: This section measures the expertise of Enterprise Administrators and Platform Engineers in distributing and managing GitHub Actions and workflows at the organizational level. It includes reuse and sharing of templates, strategies for managing reusable components via repositories and naming conventions, controlling access to actions, setting organization-wide usage policies, and planning maintenance to ensure efficient enterprise-wide deployment of GitHub Actions.

 

Free GitHub Administrator GH-200 Exam Question: https://actualtests.vceprep.com/GH-200-latest-vce-prep.html