mirror of
https://github.com/ibiqlik/action-yamllint.git
synced 2024-11-22 14:21:03 -05:00
Save yamllint output/log to a file
This commit is contained in:
parent
c19bd0523a
commit
c880b49d82
4 changed files with 53 additions and 6 deletions
16
.github/workflows/lint.yml
vendored
16
.github/workflows/lint.yml
vendored
|
@ -5,7 +5,9 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: lint with config
|
|
||||||
|
- id: lint-with-config
|
||||||
|
name: lint with config
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
file_or_dir: test
|
file_or_dir: test
|
||||||
|
@ -18,7 +20,8 @@ jobs:
|
||||||
trailing-spaces:
|
trailing-spaces:
|
||||||
level: warning
|
level: warning
|
||||||
|
|
||||||
- name: lint all - no warnings (continue on error)
|
- id: lint-all-no-warnings
|
||||||
|
name: lint all - no warnings (continue on error)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
@ -26,9 +29,16 @@ jobs:
|
||||||
strict: true
|
strict: true
|
||||||
no_warnings: true
|
no_warnings: true
|
||||||
|
|
||||||
- name: lint all (continue on error)
|
- id: lint-all-continue
|
||||||
|
name: lint all (continue on error)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
file_or_dir: test
|
file_or_dir: test
|
||||||
strict: true
|
strict: true
|
||||||
|
|
||||||
|
- id: print-output
|
||||||
|
name: Print output
|
||||||
|
run: |
|
||||||
|
echo ${{ steps.lint-with-config.outputs.logfile }}
|
||||||
|
cat ${{ steps.lint-with-config.outputs.logfile }}
|
||||||
|
|
29
README.md
29
README.md
|
@ -10,7 +10,7 @@ Simple as:
|
||||||
- uses: ibiqlik/action-yamllint@v3
|
- uses: ibiqlik/action-yamllint@v3
|
||||||
```
|
```
|
||||||
|
|
||||||
### Optional parameters
|
### Optional input parameters
|
||||||
|
|
||||||
- `config_file` - Path to custom configuration
|
- `config_file` - Path to custom configuration
|
||||||
- `config_data` - Custom configuration (as YAML source)
|
- `config_data` - Custom configuration (as YAML source)
|
||||||
|
@ -25,6 +25,12 @@ Simple as:
|
||||||
|
|
||||||
**Note:** If `.yamllint` configuration file exists in your root folder, yamllint will automatically use it.
|
**Note:** If `.yamllint` configuration file exists in your root folder, yamllint will automatically use it.
|
||||||
|
|
||||||
|
### Outputs
|
||||||
|
|
||||||
|
`logfile` - Path to yamllint log file
|
||||||
|
|
||||||
|
`${{ steps.<step>.outputs.logfile }}`
|
||||||
|
|
||||||
### Example usage in workflow
|
### Example usage in workflow
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -73,3 +79,24 @@ config_data: |
|
||||||
trailing-spaces:
|
trailing-spaces:
|
||||||
level: warning
|
level: warning
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Use output to save/upload the log in artifact. Note, you must have `id` in the step running the yamllint action.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Yaml Lint
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
lintAllTheThings:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- id: yaml-lint
|
||||||
|
uses: ibiqlik/action-yamllint@v3
|
||||||
|
|
||||||
|
- run: echo ${{ steps.yaml-lint.outputs.logfile }}
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: yamllint-logfile
|
||||||
|
path: ${{ steps.yaml-lint.outputs.logfile }}
|
||||||
|
```
|
||||||
|
|
|
@ -25,10 +25,16 @@ inputs:
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
logfile:
|
||||||
|
description: "Yamllint log file path"
|
||||||
|
value: ${{ steps.yamllint.outputs.logfile }}
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- run: ${{ github.action_path }}/entrypoint.sh
|
- id: yamllint
|
||||||
|
run: ${{ github.action_path }}/entrypoint.sh
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
INPUT_FILE_OR_DIR: ${{ inputs.file_or_dir }}
|
INPUT_FILE_OR_DIR: ${{ inputs.file_or_dir }}
|
||||||
|
|
|
@ -4,6 +4,8 @@ echo "======================"
|
||||||
echo "= Linting YAML files ="
|
echo "= Linting YAML files ="
|
||||||
echo "======================"
|
echo "======================"
|
||||||
|
|
||||||
|
LOGFILE=yamllint.log
|
||||||
|
|
||||||
if [[ -n "$INPUT_CONFIG_FILE" ]]; then
|
if [[ -n "$INPUT_CONFIG_FILE" ]]; then
|
||||||
options+=(-c "$INPUT_CONFIG_FILE")
|
options+=(-c "$INPUT_CONFIG_FILE")
|
||||||
fi
|
fi
|
||||||
|
@ -28,4 +30,6 @@ shopt -s globstar
|
||||||
options+=("${INPUT_FILE_OR_DIR:-.}")
|
options+=("${INPUT_FILE_OR_DIR:-.}")
|
||||||
shopt -u globstar
|
shopt -u globstar
|
||||||
|
|
||||||
yamllint "${options[@]}"
|
yamllint "${options[@]}" | tee -a $LOGFILE
|
||||||
|
|
||||||
|
echo "::set-output name=logfile::$(realpath ${LOGFILE})"
|
||||||
|
|
Loading…
Reference in a new issue