Update .forgejo/workflows/yamllint.yml

This commit is contained in:
Matt Reeves 2024-12-12 23:44:09 -05:00
parent f518ae43d9
commit 557c08998a

View file

@ -12,20 +12,23 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Fetch all branches
run: git fetch --all
- name: Get modified YAML files - name: Get modified YAML files
id: get_changed_files id: get_changed_files
run: | run: |
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then BASE_BRANCH=$(git merge-base HEAD origin/${{ github.event.pull_request.base.ref }})
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep -E '\.(yml)$' || true) CHANGED_FILES=$(git diff --name-only $BASE_BRANCH HEAD | grep -E '\.(yml)$' || true)
else echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
CHANGED_FILES=$(git diff --name-only $(git hash-object -t tree /dev/null) HEAD | grep -E '\.(yml)$' || true)
fi - name: Debug changed files
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV run: echo "Changed files: ${{ env.CHANGED_FILES }}"
- name: Run yamllint on modified files - name: Run yamllint on modified files
if: env.CHANGED_FILES != '' if: env.CHANGED_FILES != ''
run: | run: |
yamllint $CHANGED_FILES yamllint $CHANGED_FILES
env: env:
CHANGED_FILES: ${{ env.CHANGED_FILES }} CHANGED_FILES: ${{ env.CHANGED_FILES }}