mirror of
https://github.com/ibiqlik/action-yamllint.git
synced 2024-11-23 18:19:33 +01: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
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: lint with config
|
||||
|
||||
- id: lint-with-config
|
||||
name: lint with config
|
||||
uses: ./
|
||||
with:
|
||||
file_or_dir: test
|
||||
|
@ -18,7 +20,8 @@ jobs:
|
|||
trailing-spaces:
|
||||
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
|
||||
uses: ./
|
||||
with:
|
||||
|
@ -26,9 +29,16 @@ jobs:
|
|||
strict: true
|
||||
no_warnings: true
|
||||
|
||||
- name: lint all (continue on error)
|
||||
- id: lint-all-continue
|
||||
name: lint all (continue on error)
|
||||
continue-on-error: true
|
||||
uses: ./
|
||||
with:
|
||||
file_or_dir: test
|
||||
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
|
||||
```
|
||||
|
||||
### Optional parameters
|
||||
### Optional input parameters
|
||||
|
||||
- `config_file` - Path to custom configuration
|
||||
- `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.
|
||||
|
||||
### Outputs
|
||||
|
||||
`logfile` - Path to yamllint log file
|
||||
|
||||
`${{ steps.<step>.outputs.logfile }}`
|
||||
|
||||
### Example usage in workflow
|
||||
|
||||
```yaml
|
||||
|
@ -73,3 +79,24 @@ config_data: |
|
|||
trailing-spaces:
|
||||
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
|
||||
default: "false"
|
||||
|
||||
outputs:
|
||||
logfile:
|
||||
description: "Yamllint log file path"
|
||||
value: ${{ steps.yamllint.outputs.logfile }}
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- run: ${{ github.action_path }}/entrypoint.sh
|
||||
- id: yamllint
|
||||
run: ${{ github.action_path }}/entrypoint.sh
|
||||
shell: bash
|
||||
env:
|
||||
INPUT_FILE_OR_DIR: ${{ inputs.file_or_dir }}
|
||||
|
|
|
@ -4,6 +4,8 @@ echo "======================"
|
|||
echo "= Linting YAML files ="
|
||||
echo "======================"
|
||||
|
||||
LOGFILE=yamllint.log
|
||||
|
||||
if [[ -n "$INPUT_CONFIG_FILE" ]]; then
|
||||
options+=(-c "$INPUT_CONFIG_FILE")
|
||||
fi
|
||||
|
@ -28,4 +30,6 @@ shopt -s globstar
|
|||
options+=("${INPUT_FILE_OR_DIR:-.}")
|
||||
shopt -u globstar
|
||||
|
||||
yamllint "${options[@]}"
|
||||
yamllint "${options[@]}" | tee -a $LOGFILE
|
||||
|
||||
echo "::set-output name=logfile::$(realpath ${LOGFILE})"
|
||||
|
|
Loading…
Reference in a new issue