This commit is contained in:
Matt Reeves 2024-12-11 00:24:37 -05:00
parent 4f5d69546a
commit cfa832fb67

View file

@ -8,23 +8,25 @@ jobs:
lint: lint:
name: Lint YAML files name: Lint YAML files
runs-on: docker runs-on: docker
container:
image: cytopia/yamllint:latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Node.js - name: Get modified YAML files
uses: actions/setup-node@v4 id: get_changed_files
with:
node-version: 14
- name: Install yamllint
run: | run: |
npm install -g yaml-lint CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E '\.(yml)$' || true)
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
- name: Show yamllint version - name: Run yamllint on modified files
if: env.CHANGED_FILES != ''
run: | run: |
yamllint --version yamllint $CHANGED_FILES
env:
CHANGED_FILES: ${{ env.CHANGED_FILES }}
- name: Lint .yml files - name: Skip linting if no YAML files are changed
run: | if: env.CHANGED_FILES == ''
yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" docker/**/*.yml run: echo "No YAML files changed in this PR. Skipping lint."