Skip to content

Commit

Permalink
Add default values, exit if no input
Browse files Browse the repository at this point in the history
  • Loading branch information
ibiqlik committed Dec 17, 2019
1 parent 9ea81d4 commit 0080381
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ This action executes `yamllint` (https://github.com/adrienverge/yamllint) agains
- `file_or_dir` - Enter file/folder (space speparated), wildcards accepted. Examples:
- `file1.yaml`
- `file1.yaml file2.yaml`
- `.` - run against all yaml files in current directory recursively
- `./**/*values.yaml` - run against all files that end with `values.yaml` recursively
- `.` - 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)
- `format` - Format for parsing output [parsable,standard]
- `strict` - Return non-zero exit code on warnings as well as errors
- `format` - Format for parsing output [parsable,standard,colored,auto]
- `strict` - Return non-zero exit code on warnings as well as errors [true,false]

### Example usage in workflow

Expand All @@ -32,6 +32,6 @@ jobs:
- name: yaml-lint
uses: ibiqlik/action-yamllint@master
with:
file_or_dir: ./**/*val*.yaml
file_or_dir: myfolder/*values*.yaml
config_file: .yamllint.yml
```
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: 'ibiqlik'

inputs:
file_or_dir:
description: 'File(s) or Directory'
description: 'File(s) or Directory, separate by space if multiple files or folder are specified'
required: true
config_file:
description: 'Path to custom configuration'
Expand All @@ -13,11 +13,13 @@ inputs:
description: 'Custom configuration (as YAML source)'
required: false
format:
description: 'Format for parsing output [parsable,standard]'
description: 'Format for parsing output [parsable,standard,colored,auto]'
required: false
default: "auto"
strict:
description: 'Return non-zero exit code on warnings as well as errors'
required: false
default: "false"

runs:
using: 'docker'
Expand Down
10 changes: 8 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ echo "======================"
echo "= Linting YAML files ="
echo "======================"

if [ ! -z "$INPUT_STRICT" ]; then
if [ -z "INPUT_FILE_OR_DIR" ]; then
echo "file_or_dir not provided, add it in workflow"
exit 1
fi

STRICT=""
if [ "$INPUT_STRICT" == "true" ]; then
STRICT="-s"
fi

Expand All @@ -16,4 +22,4 @@ if [ ! -z "$INPUT_CONFIG_DATA" ]; then
CONFIG_DATA="-d $INPUT_CONFIG_DATA"
fi

yamllint $CONFIG_FILE $CONFIG_DATA $INPUT_FORMAT $STRICT $INPUT_FILE_OR_DIR
yamllint $CONFIG_FILE $CONFIG_DATA -f $INPUT_FORMAT $STRICT $INPUT_FILE_OR_DIR

0 comments on commit 0080381

Please sign in to comment.