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

When using git-lfs optimized images are incorrectly commited #50

Closed
mieszko4 opened this issue Mar 4, 2020 · 8 comments
Closed

When using git-lfs optimized images are incorrectly commited #50

mieszko4 opened this issue Mar 4, 2020 · 8 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mieszko4
Copy link

mieszko4 commented Mar 4, 2020

I have a repository with images tracked in git-lfs.
My .gitattributes:

*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text

So my configuration for github's action checkout step is:

- name: Checkout Repo
        uses: actions/checkout@master
        with:
          lfs: true # NOTE this line

Calibreapp optimizes images well but instead of committing optimized images to git-lfs it commits them directly to git repository (by creating binary files instead of pointers)

I suspect the problem is here:

// Convert image paths to blob ready objects
const treeBlobs = await convertToTreeBlobs({
owner,
repo,
images: optimisedImages
});
console.log("\t * ", "Creating tree…", owner, repo, baseTree);
// Create tree
const newTree = await api.git.createTree({
owner,
repo,
base_tree: baseTree,
tree: treeBlobs
});
console.log("\t * ", "New tree:", newTree.data.sha);
const commit = await api.git.createCommit({
owner,
repo,
message: "Optimised images with calibre/image-actions",
tree: newTree.data.sha,
parents: [mostRecentCommitSHA]
});

So I cannot use this action with my current setup :(
Do you plan to support git-lfs repositories?

@benschwarz
Copy link
Member

@mieszko4 I must admit I've never used git-lfs so at this stage I'm not aware of how to add support for it.

Would files need to be committed to lfs separately?

Are you familiar with the GitHub API? Would you be able to help implement LFS support?

@benschwarz benschwarz added enhancement New feature or request help wanted Extra attention is needed labels Mar 4, 2020
@mieszko4
Copy link
Author

mieszko4 commented Mar 4, 2020

I am also investigating it a bit now :)
The basic idea with git-lfs is that you upload files to lfs and you store just pointers (a hash) on git. Then there are filters set on git checkout that automatically downloads files from lfs

When you use it locally git commit handles all of these for you but it seems that github api does not support lfs.

I am happy to help. The following looks promising https://github.com/mikeal/publish-to-github-action

@mieszko4
Copy link
Author

mieszko4 commented Mar 4, 2020

In particular: https://github.com/mikeal/publish-to-github-action/blob/master/entrypoint.sh

In any case, if there is a way to commit directly using git commands (instead of github api) I think it would automatically resolve the problem with git lfs (since git command does things automatically)

@chiefjester
Copy link
Contributor

@benschwarz got stuck with this as well. While it correctly compressed LFS files. It doesn't commit The updated image with a pointer but a binary instead.

I think oktokit rest library doesn't seem to support LFS. So the best way to support LFS is invoke git commands in bash, or maybe call a shell script like @mieszko4 is suggesting.

Thoughts?

@tunetheweb
Copy link
Contributor

Could #54 help with this? Use the proposed compressOnly flag and then commit yourself (using checkout GitHub action or whatever)?

@chiefjester
Copy link
Contributor

hey @bazzadp yeah, that might work 👌

I do wish it's something built in with the action, like using @actions/exec for doing an actual PR. How's that sound @benschwarz ?

@benschwarz
Copy link
Member

@thisguychris, It seems like a compressOnly mode would be the best way to go. That way we would be able to configure a pipeline to compress, commit (using another LFS action), and optionally post a summary on the PR.

@benschwarz
Copy link
Member

Here's where you can find documentation about image-actions compress only mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

No branches or pull requests

4 participants