Skip to content

Commit

Permalink
Adding validation check (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBartusch authored Sep 10, 2024
1 parent 9be229c commit e77b5a5
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/validate-ootrs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Check OOTRS Files

on:
pull_request:
paths:
- '**/*.ootrs'

jobs:
check-ootrs-files:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get list of changed .ootrs files
id: changed-files
run: |
git fetch origin ${{ github.event.pull_request.base.ref }}
git diff --name-only --diff-filter=AMR origin/${{ github.event.pull_request.base.ref }} | grep '\.ootrs$' > changed_files.txt || true
- name: List changed .ootrs files
run: |
echo "Changed .ootrs files:"
cat changed_files.txt
- name: Unzip changed .ootrs files
run: |
while IFS= read -r ootrs; do
unzip -q "$ootrs" -d "${ootrs%.ootrs}"
done < changed_files.txt
- name: Check for directories in new .ootrs files
run: |
found_dirs=0
while IFS= read -r ootrs; do
if git diff --name-only --diff-filter=AMR origin/${{ github.event.pull_request.base.ref }} | grep -q "$ootrs"; then
root_dir="${ootrs%.ootrs}"
if find "$root_dir" -mindepth 1 -type d -not -path "./.git*" | grep -q .; then
echo "Directory found in new '${ootrs}':"
find "$root_dir" -mindepth 1 -type d -not -path "./.git*"
found_dirs=1
fi
fi
done < changed_files.txt
if [ $found_dirs -eq 1 ]; then
echo "One or more directories found in new .ootrs files. Make sure your archives only contain root level entries."
exit 1
else
echo "No directories found in new .ootrs files."
fi

0 comments on commit e77b5a5

Please sign in to comment.