Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude_file input option #2

Merged
merged 10 commits into from
Mar 30, 2023
Merged

exclude_file input option #2

merged 10 commits into from
Mar 30, 2023

Conversation

GrantBirki
Copy link
Owner

@GrantBirki GrantBirki commented Mar 29, 2023

exclude_file input option

This pull request introduces a new input option for the Action:

  • exclude_file - The full path to a file in the repository where this Action is running that contains a list of '.gitignore'-style patterns to exclude files from validation (e.g. ./exclude.txt)

Excluding Files

Now, there are three main ways you can go about excluding files from being validated with this Action:

  • json_exclude_regex - A regex string that will be used to exclude JSON files from being validated
  • yaml_exclude_regex - A regex string that will be used to exclude YAML files from being validated
  • exclude_file - best way to exclude files - A file that contains a list of files to exclude from being validated in gitignore format

It should be strongly noted that both json_exclude_regex and yaml_exclude_regex options get unwieldy very quickly and are not recommended. The exclude_file option is the best way to exclude files from being validated. Especially if you have a large repository with many files.
Example of an exclude_file's contents:

# exclude all files in the test/ directory
test/

# exclude a yaml file at an exact path
src/cool-path/example.yaml

# exclude all json files with some glob matching
*.test.json

If the file path to your exclude_file is exclude.txt, you would set the exclude_file input to exclude.txt like so:

# checkout the repository
- uses: actions/checkout@v3.5.0

- name: json-yaml-validate
  uses: GrantBirki/json-yaml-validate@vX.X.X # replace with the latest version
  with:
    exclude_file: exclude.txt # gitignore style file that contains a list of files to exclude

@GrantBirki GrantBirki added the enhancement New feature or request label Mar 29, 2023
@GrantBirki GrantBirki merged commit df3037e into main Mar 30, 2023
@GrantBirki GrantBirki deleted the exclude-file branch March 30, 2023 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant