Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git actions and LFS cache

trying to mitigate large LFS pulls from github. incurring cost.
so was happy to see caching of large blob coming from LFS is supported in github actions.

here is sample posted on issue #165 at the actions/checkout module repo

- name: Checkout code
  uses: actions/checkout@v2

- name: Create LFS file list
  run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id

- name: Restore LFS cache
  uses: actions/cache@v2
  id: lfs-cache
  with:
    path: .git/lfs
    key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1

- name: Git LFS Pull
  run: git lfs pull

- name: run compile and package
  run: python CompileAndPackage.py

my current flow is the following, i declare support for lfs and set submodules support to recursive. the git LFS i call is inside a submodule.

how should i integrate the above into my flow, below.

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          lfs: 'true'
          # recursively checkout submodules.
          submodules: recursive

i'm not certain the checkout and submodule update (where the lfs pulling i assume occurs) will happen before i check the cache.

here is what i think of using

    steps:
      - uses: actions/checkout@v2
        with:
          lfs: 'true'
          submodules: recursive
          ssh-key: ${{ secrets.git_key }}
      - name: Create LFS file list
        run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
      
      - name: Restore LFS cache
        uses: actions/cache@v2
        id: lfs-cache
        with:
        path: .git/lfs
        key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
      
      - name: Git LFS Pull
        run: git lfs pull

should i be explicit about calling git submodule update --init AFTER i check the cache? afaik it happens automagicly by actions/checkout

UPDATE

hey, that looks like it actually worked!

unfrountly github doesnt go into details regarding who took a bite of the LFS quota. would be glad to hear someone says it is legit.

enter image description here

like image 728
yoshco Avatar asked Aug 03 '26 11:08

yoshco


1 Answers

I created an action for this, action-cached-lfs-checkout.

Instead of

- name: Checkout code
  uses: actions/checkout@v2
  with:
    lfs: true

simply do

- name: Checkout code
  uses: nschloe/action-cached-lfs-checkout@v1
like image 189
Nico Schlömer Avatar answered Aug 05 '26 08:08

Nico Schlömer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!