GH-500 practice question 5 of 15

– [Configure GitHub Actions Workflows] As a repository owner, you do not want to run a GitHub Actions workflow when changes are made to any .txt or markdown files. How would you adjust the event trigger for a pull request that targets the main branch? (Each answer presents part of the solution. Choose three.) on: pull_request: branches: [main]

Full set: 75 questions
Answer options
A: - '/*.md' Correct answer
B: - '/*.txt' Correct answer
C: paths:
D: paths-ignore: Correct answer
E: - 'docs/*.md'
Correct Answer:
A. - '/*.md'; B. - '/*.txt'; D. paths-ignore:
Explanation

To prevent a GitHub Actions workflow from running on a pull request when only specific file types are changed, you use the paths-ignore filter. This key is nested under the event trigger, in this case, pullrequest. The paths-ignore key accepts a list of file path patterns. The workflow will not run if all changed files in the pull request match at least one of the patterns in this list. The options '/.md' and '/.txt' specify patterns to ignore markdown and text files in the root directory, respectively.

Why Incorrect

C. paths: This key is used to include paths. The workflow would only run if changes occurred in the specified paths, which is the opposite of the desired behavior.
E. - 'docs/.md': This pattern is too specific. It would only ignore markdown files within the docs directory, failing to meet the requirement to ignore any markdown file.

References

1. GitHub Docs

"Workflow syntax for GitHub Actions": Under the section on..paths-ignore

the documentation states: "When you use paths-ignore

the workflow will not run if the only changed files match at least one of the paths-ignore patterns." This confirms the use of paths-ignore to exclude file patterns from triggering a workflow. The examples provided show the list format using hyphens (-).

Reference Location: on > on.. > on..paths-ignore

2. GitHub Docs

"Events that trigger workflows": In the section for the pullrequest event

the documentation details the available filters

including branches

paths

and paths-ignore. It clarifies that paths and paths-ignore are mutually exclusive and cannot be used in the same trigger configuration.

Reference Location: Events that trigger workflows > pullrequest > Using filters

Scroll to Top