|
11 | 11 | - main
|
12 | 12 | types: [ labeled, opened, synchronize, reopened ]
|
13 | 13 | jobs:
|
| 14 | + # Prime a single LFS cache and expose the exact key for the matrix |
| 15 | + WarmLFS: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + lfs_key: ${{ steps.expose-key.outputs.lfs_key }} |
| 19 | + steps: |
| 20 | + - name: Git Config |
| 21 | + shell: bash |
| 22 | + run: | |
| 23 | + git config --global core.autocrlf false |
| 24 | + git config --global core.longpaths true |
| 25 | +
|
| 26 | + - name: Git Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + submodules: recursive |
| 31 | + |
| 32 | + # Deterministic list of LFS object IDs, then compute a portable key: |
| 33 | + # - `git lfs ls-files -l` lists all tracked LFS objects with their SHA-256 |
| 34 | + # - `awk '{print $1}'` extracts just the SHA field |
| 35 | + # - `sort` sorts in byte order (hex hashes sort the same everywhere) |
| 36 | + # This ensures the file content is identical regardless of OS or locale |
| 37 | + - name: Git Create LFS id list |
| 38 | + shell: bash |
| 39 | + run: git lfs ls-files -l | awk '{print $1}' | sort > .lfs-assets-id |
| 40 | + |
| 41 | + - name: Git Expose LFS cache key |
| 42 | + id: expose-key |
| 43 | + shell: bash |
| 44 | + env: |
| 45 | + LFS_KEY: lfs-${{ hashFiles('.lfs-assets-id') }}-v1 |
| 46 | + run: echo "lfs_key=$LFS_KEY" >> "$GITHUB_OUTPUT" |
| 47 | + |
| 48 | + - name: Git Setup LFS Cache |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + path: .git/lfs |
| 52 | + key: ${{ steps.expose-key.outputs.lfs_key }} |
| 53 | + |
| 54 | + - name: Git Pull LFS |
| 55 | + shell: bash |
| 56 | + run: git lfs pull |
| 57 | + |
14 | 58 | Build:
|
| 59 | + needs: WarmLFS |
15 | 60 | strategy:
|
16 | 61 | matrix:
|
17 | 62 | isARM:
|
@@ -88,16 +133,12 @@ jobs:
|
88 | 133 | fetch-depth: 0
|
89 | 134 | submodules: recursive
|
90 | 135 |
|
91 |
| - # See https://github.com/actions/checkout/issues/165#issuecomment-657673315 |
92 |
| - - name: Git Create LFS FileList |
93 |
| - run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id |
94 |
| - |
| 136 | + # Use the warmed key from WarmLFS. Do not recompute or recreate .lfs-assets-id here. |
95 | 137 | - name: Git Setup LFS Cache
|
96 | 138 | uses: actions/cache@v4
|
97 |
| - id: lfs-cache |
98 | 139 | with:
|
99 | 140 | path: .git/lfs
|
100 |
| - key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 |
| 141 | + key: ${{ needs.WarmLFS.outputs.lfs_key }} |
101 | 142 |
|
102 | 143 | - name: Git Pull LFS
|
103 | 144 | run: git lfs pull
|
|
0 commit comments