How should you print a debug message in your workflow?
Answer(s): A
Example: Setting a debug message echo "::debug::Set the Octocat variable"
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands
As a developer, you are designing a workflow and need to communicate with the runner machine to set environment variables, output values used by other actions, add debug messages to the output logs, and other tasks. Which of the following options should you use?
Answer(s): E
Workflow commands for GitHub ActionsYou can use workflow commands when running shell commands in a workflow or in an action's code.About workflow commandsActions can communicate with the runner machine to set environment variables, output values used by other actions, add debug messages to the output logs, and other tasks.Most workflow commands use the echo command in a specific format, while others are invoked by writing to a file.
When should you use the GITHUB_TOKEN in a workflow?
Use GITHUB_TOKEN for authentication in workflowsAt the start of each workflow job, GitHub automatically creates a unique GITHUB_TOKEN secret to use in your workflow. You can use the GITHUB_TOKEN to authenticate in the workflow job.
https://docs.github.com/en/actions/tutorials/authenticate-with-github_token
In which of the following scenarios should you use self-hosted runners? (Each correct answer presents a complete solution. Choose two.)
Answer(s): B,C
[B] You can use self-hosted runner to run more than 6 hours job.Self-hosted runners give you the opportunity to persist whatever you like for your jobs and not be subject to the six-hour time-out in hosted virtual environments.[C] Give you more control of hardware, operating system, and software tools than GitHub-hosted runners provide.All runners can run Linux, Windows, or macOS.Incorrect:[Not A, not E]GitHub-hosted runners are fully managed on GitHub’s infrastructure using pre-configured Windows, Linux, and macOS virtual machines. In addition to offering standard runners for typical workloads, hosted runners offer larger runners with more resources (memory, CPU, and storage), custom images, static IP ranges, and Azure Virtual Network integration for enhanced security control.[Not D]GitHub Actions minutes refer to the amount of time your workflows, such as CI/CD pipelines, run on GitHub's hosted runners. Each time you trigger GitHub Actions (e.g., for testing, building, or deploying code), it consumes a portion of your available minutes.5 Dec 2024
https://github.com/orgs/community/discussions/26679https://docs.github.com/en/enterprise-cloud@latest/admin/managing-github-actions-for-your-enterprise/getting-started-with-github-actions-for-your-enterprise/getting-started-with-self-hosted-runners-for-your-enterprise https://docs.github.com/en/enterprise-cloud@latest/actions/concepts/runners/self-hosted-runners
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?
Answer(s): C
Creating Redis service containersYou 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 jobThe 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 5ports:# Maps port 6379 on service container to the host- 6379:6379
https://docs.github.com/en/actions/tutorials/use-containerized-services/create-redis-service-containers
As a developer, you want to review the step that caused a workflow failure and the failed step's build logs, First navigate to the main page of the repository on GitHub, Which section contains the step failure information?
To view a failed step and its build logs in GitHub Actions, you must navigate to the Actions section of your repository.The Actions tab is the dedicated space in any GitHub repository for managing, viewing, and debugging automated workflows. Clicking this tab allows you to see the history of all workflow runs, select the specific failed run, drill down into individual jobs, and expand the precise step that caused the error to read its execution logs.
https://blog.devgenius.io/devops-beginners-project-3-build-a-python-ci-cd-pipeline-with-github-actions-677635 9e096b
By default, which workflows can use an action stored in internal repository? (Each answer presents a complete solution. Choose two.)
Answer(s): B,D
Any actions or reusable workflows stored in the internal or private repository can be used in workflows defined in other internal or private repositories owned by the same organization, or by any organization owned by the enterprise.
https://docs.github.com/actions/creating-actions/sharing-actions-and-workflows-with-your-enterprise
You have a GitHub Actions workflow YAML file that contains the following lines.Which two statements accurately describe the behavior of the workflow? Each correct answer presents a complete solution.Note: Each correct selection is worth one point.
[C]By using the needs keyword, you create a sequential dependency. If the build job fails or is skipped, the publish-npm job will not run by default.In a GitHub Actions workflow, a job with the needs keyword will run only if the jobs it needs complete successfully or are skipped without an error. By default, if a dependency fails, the dependent job (in this case, publish-npm) is automatically skipped.To make the publish-npm job run even if the build job fails, you must use a conditional expression, such as if: always() or if: success() || failure().[B, not A]We see in the last line of code that an NPM token is used for authentication-Note:When publishing a Node.js package using GitHub Actions, the primary differences between using the npm registry and GitHub Packages involve authentication methods, registry configuration, and package naming requirements.Key Differences at a Glance*-> Authentication .For npm RegistryRequires a manually created npm token stored as a secretFor GitHub PackagesCan use the built-in GITHUB_TOKEN automatically provided by GitHub.
https://blog.anoff.io/2020-07-private-npm-package-github https://dev.to/gervaisamoah/introduction-to-github-actions-easy-guide-3p23
Share your comments for Microsoft GH-200 exam with other users:
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 }}
$VARIABLE
GITHUB_
defaults:
run
GITHUB_WORKSPACE
${{ github.workspace }}
$GITHUB_WORKSPACE/...
${{ github.workspace }}/...