Created
December 13, 2017 15:13
-
-
Save valscion/32d3a90633d722f46ac1428c7b8177a4 to your computer and use it in GitHub Desktop.
Depfu + Git LFS + CircleCI. MIT licensed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
steps: | |
- checkout | |
- run: ssh git@github.com git-lfs-authenticate venuu/venuu.git download | |
- run: | |
name: Pull LFS files | |
command: |- | |
git lfs install | |
git lfs pull | |
- run: | |
name: Fix LFS files committed as regular binary files | |
command: ./script/ci/fix_non_lfs_files.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Automatically overwrites commits that have invalid LFS files | |
set -eo pipefail | |
if [ "$CIRCLE_BRANCH" = "master" ]; then | |
echo "Skipping LFS file check for master branch" | |
exit 0 | |
fi | |
# If we don't have a clean tree, it means that LFS files weren't committed correctly | |
# https://stackoverflow.com/a/3879077 | |
if (git diff-index --quiet HEAD); then | |
echo "All LFS files OK" | |
else | |
echo "HEAD contains changes directly after a checkout." | |
echo "Some LFS files were probably committed as regular binary files." | |
echo | |
git status | |
echo | |
echo "Overriding the commit and failing this current build." | |
echo | |
# Echo all commands ran from now for better debuggability | |
set -x | |
# Reset anything that might be accidentally committed | |
git reset | |
# Add only files that were added in the commit pointed by HEAD | |
git diff-tree --no-commit-id --name-only --diff-filter=A -r HEAD | xargs git add | |
git config --global user.name "Venuusaur" | |
git config --global user.email "venuusaur@venuu.fi" | |
git commit --reuse-message=HEAD --amend | |
git push --force-with-lease origin "$CIRCLE_BRANCH" | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment