Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow for checking git-lfs files #1194

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/git-lfs-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check git-lfs files

on:
push:
branches: [ 'main', 'release-*' ]
pull_request:
branches: [ 'main', 'release-*' ]

jobs:
git-lfs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true

- name: Check git-lfs files
run: |

files=$(git diff --name-only origin/main...HEAD | grep '\.o$' || true)
if [ -z "$files" ]; then
echo "No .o files modified"
exit 0
fi

for file in $files; do
contents=$(git cat-file -p :$file)

# Check if the file is binary or an LFS pointer
if [[ $contents == *"version https://git-lfs.github.com/spec/v1"* ]]; then
echo "The file '$file' is correctly tracked by LFS."
elif [[ ! $contents =~ ^[[:print:]]*$ ]]; then
echo "Error: The file '$file' is a binary file and should not be committed directly."
exit 1
fi
done

Loading