iac/.forgejo/workflows/yamllint.yml

34 lines
1.1 KiB
YAML

on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
lint:
name: Lint YAML files
runs-on: docker
container:
image: mafyuh/node-yamllint:v1.0.0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get modified YAML files
id: get_changed_files
run: |
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep -E '\.(yml)$' || true)
else
CHANGED_FILES=$(git diff --name-only $(git hash-object -t tree /dev/null) HEAD | grep -E '\.(yml)$' || true)
fi
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
- name: Run yamllint on modified files
if: env.CHANGED_FILES != ''
run: |
yamllint $CHANGED_FILES
env:
CHANGED_FILES: ${{ env.CHANGED_FILES }}
- name: Skip linting if no YAML files are changed
if: env.CHANGED_FILES == ''
run: echo "No YAML files changed in this PR. Skipping lint."