Merge pull request #1 from ruzickap/enhancement-default_path

Use the current directory as default path for yamllint
This commit is contained in:
Ilir Bekteshi 2020-01-27 12:06:14 +01:00 committed by GitHub
commit 26e96b30f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 13 deletions

View file

@ -4,18 +4,15 @@ This action executes `yamllint` (https://github.com/adrienverge/yamllint) agains
## Usage
### Required parameters
- `file_or_dir` - Enter file/folder (space speparated), wildcards accepted. Examples:
- `file1.yaml`
- `file1.yaml file2.yaml`
- `.` - run against all yaml files in a directory recursively
- `kustomize/**/*.yaml mychart/*values.yaml`
### Optional parameters
- `config_file` - Path to custom configuration
- `config_data` - Custom configuration (as YAML source)
- `file_or_dir` - Enter file/folder (space separated), wildcards accepted. Examples:
- `.` - run against all yaml files in a directory recursively (default)
- `file1.yaml`
- `file1.yaml file2.yaml`
- `kustomize/**/*.yaml mychart/*values.yaml`
- `format` - Format for parsing output [parsable,standard,colored,auto]
- `strict` - Return non-zero exit code on warnings as well as errors [true,false]
@ -35,3 +32,17 @@ jobs:
file_or_dir: myfolder/*values*.yaml
config_file: .yamllint.yml
```
Or just simply check all yaml files in the repository:
```yaml
name: Yaml Lint
on: [push]
jobs:
lintAllTheThings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: yaml-lint
uses: ibiqlik/action-yamllint@master
```

View file

@ -4,10 +4,8 @@ echo "======================"
echo "= Linting YAML files ="
echo "======================"
if [ -z "INPUT_FILE_OR_DIR" ]; then
echo "file_or_dir not provided, add it in workflow"
exit 1
fi
# Use the current directory by default
export INPUT_FILE_OR_DIR=${INPUT_FILE_OR_DIR:-.}
STRICT=""
if [ "$INPUT_STRICT" == "true" ]; then
@ -22,4 +20,4 @@ if [ ! -z "$INPUT_CONFIG_DATA" ]; then
CONFIG_DATA="-d $INPUT_CONFIG_DATA"
fi
yamllint $CONFIG_FILE $CONFIG_DATA -f $INPUT_FORMAT $STRICT $INPUT_FILE_OR_DIR
yamllint $CONFIG_FILE $CONFIG_DATA -f $INPUT_FORMAT $STRICT $INPUT_FILE_OR_DIR