Question 1
Multiple choice
GitHub-hosted runners support which capabilities? (Each correct answer presents a complete solution. Choose two.)
-
A
support for Linux, Windows, and macOS
-
B
support for a variety of Linux variations including CentOS, Fedora, and Debian
-
C
requiring a payment mechanism (e.g., credit card) to use for private repositories
-
D
automatic file-system caching between workflow runs
-
E
automatic patching of both the runner and the underlying OS
Reveal answer details
Close answer details
Correct answersA, E
Explanation[A, not B] Each GitHub-hosted runner is a new virtual machine (VM) hosted by GitHub with the runner application and other tools preinstalled, and is available with Ubuntu Linux, Windows, or macOS operating systems. [E] When you use a GitHub-hosted runner, machine maintenance and upgrades are taken care of for you. References: https://docs.github.com/en/[email protected]/actions/concepts/runners/github-hosted-runners
Question 2
Multiple choice
How can a workflow deploy mitigate the risk of multiple workflow runs that are deploying to a single cloud environment simultaneously? (Each correct answer presents part of the solution. Choose two.)
-
A
Reference the mutex in the task performing the deployment.
-
B
Set the concurrency in the deploymentjob to 1.
-
C
Specify a target environment in the deploymentjob.
-
D
Specify a concurrency scope in the workflow.
-
E
Configure the mutex setting in the environment.
-
F
Pass the mutex into the deployment job.
Reveal answer details
Close answer details
Correct answersC, D
Explanation[D] GitHub Actions now supports a concurrency key at both the workflow and job level that will ensure that only a single run or job is in progress. concurrency Use concurrency to ensure that only a single job or workflow using the same concurrency group will run at a time. Example: Using concurrency and the default behavior. The default behavior of GitHub Actions is to allow multiple jobs or workflow runs to run concurrently. The concurrency keyword allows you to control the concurrency of workflow runs. For example, you can use the concurrency keyword immediately after where trigger conditions are defined to limit the concurrency of entire workflow runs for a specific branch: on: push: branches: -main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true Incorrect: [Not A, not E, Not F] actions-mutex A GitHub Action for exclusive control. FEATURE avoid running multiple jobs concurrently across workflows OFFICIAL CONCURRENCY SUPPORT ON GITHUB ACTIONS The action is no longer maintained. On April 19, 2021, GitHub launched support for limiting concurrency in the workflow files References: https://github.blog/changelog/2021-04-19-github-actions-limit-workflow-run-or-job-concurrency/ https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#concurrency https://github.com/marketplace/actions/actions-mutex
Question 3
Multiple choice
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 standard GitHub-hosted runners since their IP addresses are automatically allowed.
-
B
You can use self-hosted runners with known IP addresses.
-
C
You must allow GitHub Actions's IP address ranges in order to use marketplace actions.
-
D
You can use GitHub-hosted larger runners since they can be configured with static IP addresses.
Reveal answer details
Close answer details
Correct answersB, D
ExplanationUsing 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. References: 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
When should you use the GITHUB_TOKEN in a workflow?
-
A
when you want to make authenticated calls to the GitHub API
-
B
when you want to connect to the runner via SSH
-
C
when you want to access repository-level secrets
-
D
when you want to call an action from the marketplace
Reveal answer details
Close answer details
Correct answerA
ExplanationUse GITHUB_TOKEN for authentication in workflows At 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. References: https://docs.github.com/en/actions/tutorials/authenticate-with-github_token
Question 5
Multiple choice
Which of the following scenarios requires a developer to explicitly use the GITHUB_TOKEN or github.token secret within a workflow? (Choose two.)
-
A
passing the GITHUB_TOKEN secret to an action that requires a token as an input
-
B
making an authenticated GitHub API request
-
C
checking out source code with the actions/checkout@v3 action
-
D
assigning non-default permissions to the GITHUB_TOKEN
Reveal answer details
Close answer details
Correct answersA, B
Explanation[A] Some actions may require a GITHUB_TOKEN as an input to authenticate and perform specific tasks, such as creating issues, commenting on pull requests, or interacting with the GitHub API. In such cases, you would need to explicitly pass the token to the action. [B] When making an authenticated GitHub API request, the GITHUB_TOKEN is required to authenticate the request. This token is automatically provided by GitHub in the workflow, and it must be explicitly used when interacting with the GitHub API. Note: You can use the GITHUB_TOKEN to make authenticated API calls. This example workflow creates an issue using the GitHub REST API: name: Create issue on commit on: [ push ] jobs: create_issue: runs-on: ubuntu-latest permissions: issues: write steps: -name: Create issue using REST API run: | curl --request POST \ --url https://api.github.com/repos/${{ github.repository }}/issues \ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ --header 'content-type: application/json' \ --data '{ "title": "Automated issue for commit: ${{ github.sha }}", "body": "This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n The commit hash was: _${{ github.sha }}_." }' \ --fail References: https://docs.github.com/en/actions/tutorials/authenticate-with-github_token
Question 6
Multiple choice
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? (Each correct answer presents part of the solution. Choose two.)
-
A
path: the file path on the runner to cache or restore
-
B
dependency: the name and version of a package to cache or restore
-
C
key: the key created when saving a cache and the key used to search for a cache
-
D
restore-keys: the copy action key used with cache parameter to cache the data
-
E
cache-hit: the copy action key used with restore parameter to restore the data from the cache
-
F
ref: the ref name of the branch to access and restore a cache created
Reveal answer details
Close answer details
Correct answersA, C
ExplanationInput parameters for the cache action [C] key: Required. The key created when saving a cache and the key used to search for a cache. It can be any combination of variables, context values, static strings, and functions. Keys have a maximum length of 512 characters, and keys longer than the maximum length will cause the action to fail. [A] path: Required. The path(s) on the runner to cache or restore. Incorrect: restore-keys: Optional enableCrossOsArchive: Optional References: https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching
Which workflow event is used to manually trigger a workflow run?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerB
ExplanationManually running a workflow. When a workflow is configured to run on the workflow_dispatch event, you can run the workflow using the Actions tab on GitHub, GitHub CLI, or the REST API. Configuring a workflow to run manually To run a workflow manually, the workflow must be configured to run on the workflow_dispatch event. To trigger the workflow_dispatch event, your workflow must be in the default branch. References: https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow
What is the right method to ensure users approve a workflow before the next step proceeds?
-
A
creating a branch protection rule and only allow certain users access
-
B
granting users workflow approval permissions
-
C
adding users as required reviewers for an environment
-
D
granting users repository approval permission
Reveal answer details
Close answer details
Correct answerC
ExplanationGitHub Actions allows you to configure environment protection rules, where you can require specific users or teams to approve the deployment before the workflow proceeds to the next step. This ensures that the required reviewers approve the workflow before any sensitive actions (such as deployment) occur. Note: Managing environments for deployment You can create environments and secure those environments with deployment protection rules. A job that references an environment must follow any protection rules for the environment before running or accessing the environment's secrets. Optionally, you can specify people or teams that must approve workflow jobs that use this environment. Select Required reviewers. Enter up to 6 people or teams. Only one of the required reviewers needs to approve the job for it to proceed. Optionally, to prevent users from approving workflows runs that they triggered, select Prevent self-review. Click Save protection rules. References: https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments
Question 9
Multiple choice
A workflow that had been working now stalls in a waiting state until failing. The workflow file process-ml.yaml has not changed and contains jobs specifying runs-on: [gpu ]. Which of the following steps would troubleshoot the issue? (Each answer presents a complete solution. Choose two.)
-
A
Review the contents of the Runner_*.log files in the_diag folder.
-
B
Increase the usage limits for the GitHub-hosted runners.
-
C
Check the "Set up job" step for the logs of the last successful run to determine the runner.
-
D
Update the org settings to enable GPU-based GitHub-hosted runners.
-
E
Rotate the GITHUB_TOKEN secret for the appropriate runners.
Reveal answer details
Close answer details
Correct answersA, D
ExplanationMonitoring and troubleshooting self-hosted runners You can monitor your self-hosted runners to view their activity and diagnose common issues. [A] Reviewing the self-hosted runner application log files You can monitor the status of the self-hosted runner application and its activities. Log files are kept in the_diag directory where you installed the runner application, and a new log is generated each time the application is started. The filename begins with Runner_, and is followed by a UTC timestamp of when the application was started. [D] You can choose one of the standard GitHub-hosted runner options or, if you are on the GitHub Team or GitHub Enterprise Cloud plan, you can provision a runner with more cores, or a runner that's powered by a GPU processor. These machines are referred to as "larger runner." References: https://docs.github.com/en/actions/how-tos/manage-runners/self-hosted-runners/monitor-and-troubleshoot https://docs.github.com/en/actions/concepts/runners/github-hosted-runners
Question 10
Single choice
Scheduled workflows run on the:
-
A
specified commit and branch from the workflow YAML file.
-
B
latest commit from the branch named schedule.
-
C
latest commit and branch on which the workflow was triggered.
-
D
latest commit from the branch named main.
-
E
latest commit on the default or base branch.
Reveal answer details
Close answer details
Correct answerE
ExplanationScheduled workflows run on the latest commit on the default branch. Note: The default branch is also the initial branch that Git checks out locally when someone clones the repository. Unless you specify a different branch, the default branch in a repository is the base branch for new pull requests and code commits. References: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax https://docs.github.com/articles/about-branches
Question 11
Multiple choice
Which choices represent best practices for publishing actions so that they can be consumed reliably? (Each correct answer presents a complete solution. Choose two.)
-
A
-
B
-
C
-
D
-
E
Reveal answer details
Close answer details
Correct answersB, D
ExplanationSecurity practices for writing workflows and using GitHub Actions features. You can help mitigate this risk by following these good practices: [B] Pin actions to a full-length commit SHA Pinning an action to a full-length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. When selecting a SHA, you should verify it is from the action's repository and not a repository fork. [D] Pin actions to a tag only if you trust the creator Although pinning to a commit SHA is the most secure option, specifying a tag is more convenient and is widely used. If you'd like to specify a tag, then be sure that you trust the action's creators. The 'Verified creator' badge on GitHub Marketplace is a useful signal, as it indicates that the action was written by a team whose identity has been verified by GitHub. Note that there is risk to this approach even if you trust the author, because a tag can be moved or deleted if a bad actor gains access to the repository storing the action. References: https://docs.github.com/en/actions/reference/security/secure-use
Question 12
Single choice
Which default GitHub environment variable indicates the owner and repository name?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerA
ExplanationVariables reference Find information for supported variables, naming conventions, limits, and contexts in GitHub Actions workflows. Variables include:*GITHUB_REPOSITORY The owner and repository name. For example, octocat/Hello- World* Etc. References: https://docs.github.com/en/actions/reference/workflows-and-actions/variables
Question 13
Multiple choice
Custom environment variables can be defined at multiple levels within a workflow file including: (Each answer presents a complete solution. Choose three.)
-
A
-
B
-
C
-
D
-
E
-
F
Reveal answer details
Close answer details
Correct answersA, B, E
ExplanationDefining environment variables for a single workflow To set a custom environment variable for a single workflow, you can define it using the env key in the workflow file. The scope of a custom variable set by this method is limited to the element in which it is defined. You can define variables that are scoped for: The entire workflow, by using env at the top level of the workflow file. The contents of a job within a workflow, by using jobs.<job_id>.env. A specific step within a job, by using jobs.<job_id>.steps[*].env. References: https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-variables
Question 14
Single choice
You need to execute a matrix job that builds across 3 Node versions and 2 OS types. How many runs will GitHub create?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerC
ExplanationMatrix jobs multiply combinations of defined variables. Example: matrix: node: [14, 16, 18] os: [ubuntu-latest, windows-latest] --->3 x 2 = 6 total runs.
Question 15
Multiple choice
While writing a custom action, some behavior within the runner must be changed. Which workflow commands would set an error message in the runner's output? (Each correct answer presents a complete solution. Choose two.)
-
A
echo "::error file=main.py,line=10,col=15::There was an error"
-
B
echo "::error=There was an error::"
-
C
echo "::error::There was an error"
-
D
echo "::error message=There was an error::"
Reveal answer details
Close answer details
Correct answersA, C
ExplanationTo set an error message in a GitHub Actions runner's output, you should use the command echo "::error::Your error message" in your workflow's run step. This workflow command creates an error annotation that will appear in the logs, and you can optionally include file and line number information, such as echo "::error file=app.js,line=5::Error message". Example Simple Error. steps: -name: My Step run: echo "::error::Something went wrong in this step." Error with File and Line Information. steps: -name: My Step run: echo "::error file=src/main.py,line=25::Invalid syntax detected." References: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands
|