Output log files #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint YAML (yamllint) | |
| on: | |
| push: | |
| paths: | |
| - "**/*.yml" | |
| - "**/*.yaml" | |
| pull_request: | |
| paths: | |
| - "**/*.yml" | |
| - "**/*.yaml" | |
| permissions: | |
| contents: read | |
| jobs: | |
| yamllint: | |
| runs-on: ubuntu-latest | |
| if: github.actor != 'github-actions[bot]' | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect YAML files | |
| id: detect | |
| run: | | |
| set -euo pipefail | |
| has_yaml=false | |
| git ls-files | grep -E '\.(yml|yaml)$' -m1 >/dev/null 2>&1 && has_yaml=true || true | |
| echo "has_yaml=$has_yaml" >> "$GITHUB_OUTPUT" | |
| echo "Detected: yaml=$has_yaml" | |
| - name: Install yamllint (only if needed/missing) | |
| if: steps.detect.outputs.has_yaml == 'true' | |
| run: | | |
| set -euo pipefail | |
| if ! command -v yamllint >/dev/null 2>&1; then | |
| sudo apt-get update | |
| sudo apt-get install -y yamllint | |
| fi | |
| yamllint --version | |
| - name: Run yamllint (temp config in /tmp) | |
| if: steps.detect.outputs.has_yaml == 'true' | |
| run: | | |
| set -euo pipefail | |
| cat > /tmp/yamllint.yml <<'YAML' | |
| extends: default | |
| rules: | |
| indentation: | |
| spaces: 2 | |
| indent-sequences: consistent | |
| line-length: | |
| max: 200 | |
| allow-non-breakable-words: true | |
| allow-non-breakable-inline-mappings: true | |
| document-start: disable | |
| truthy: disable | |
| YAML | |
| # Lint only tracked YAML files | |
| git ls-files | grep -E '\.(yml|yaml)$' | xargs -r yamllint -c /tmp/yamllint.yml | |
| - name: No-op (no YAML files) | |
| if: steps.detect.outputs.has_yaml != 'true' | |
| run: | | |
| echo "No YAML files tracked; skipping." |