iac/.forgejo/workflows/yamllint.yml

38 lines
1.1 KiB
YAML
Raw Normal View History

2024-07-12 23:57:29 -04:00
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
lint:
name: Lint YAML files
runs-on: docker
2024-12-11 00:24:37 -05:00
container:
2024-12-11 20:25:08 -05:00
image: mafyuh/node-yamllint:v1.0.0
2024-07-12 23:57:29 -04:00
steps:
- name: Checkout code
uses: actions/checkout@v4
2024-12-12 23:44:09 -05:00
- name: Fetch all branches
run: git fetch --all
2024-12-11 00:24:37 -05:00
- name: Get modified YAML files
id: get_changed_files
run: |
2024-12-12 23:44:09 -05:00
BASE_BRANCH=$(git merge-base HEAD origin/${{ github.event.pull_request.base.ref }})
CHANGED_FILES=$(git diff --name-only $BASE_BRANCH HEAD | grep -E '\.(yml)$' || true)
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
- name: Debug changed files
run: echo "Changed files: ${{ env.CHANGED_FILES }}"
2024-07-12 23:57:29 -04:00
2024-12-11 00:24:37 -05:00
- name: Run yamllint on modified files
if: env.CHANGED_FILES != ''
run: |
2024-12-12 23:44:09 -05:00
yamllint $CHANGED_FILES
2024-12-11 00:24:37 -05:00
env:
CHANGED_FILES: ${{ env.CHANGED_FILES }}
2024-07-12 23:57:29 -04:00
2024-12-11 00:24:37 -05:00
- name: Skip linting if no YAML files are changed
if: env.CHANGED_FILES == ''
2024-12-12 23:38:09 -05:00
run: echo "No YAML files changed in this PR. Skipping lint."