Skip to content

Commit fdbfffc

Browse files
authored
Improve action (#6)
- Avoid checkout all history in order to reduce LFS data size - Save cache save/restore to ensure only producer upload to the cache - Upload artifacts even on cache hit so that cache instability are fixed - Fix artifact workflow by reinit the git repo after download
1 parent e90cd07 commit fdbfffc

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
type: 'producer'
3333
repository: 'f3d-app/f3d'
34-
cache_postfix: 'ci-cache'
34+
cache_postfix: 'ci-cache-0'
3535

3636
- name: Set output
3737
id: lfs_sha
@@ -67,7 +67,7 @@ jobs:
6767
type: 'consumer'
6868
repository: 'f3d-app/f3d'
6969
lfs_sha: ${{ needs.cache_lfs.outputs.lfs_sha}}
70-
cache_postfix: 'ci-cache'
70+
cache_postfix: 'ci-cache-0'
7171
target_directory: 'output_dir'
7272

7373
- name: Check output has expected size

action.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ runs:
5959
shell: bash
6060
run: echo "lfs_data_cache_sha=${{inputs.lfs_sha}}" >> $GITHUB_ENV
6161

62-
- name: Cache LFS data
62+
- name: Restore cached LFS data
6363
id: cache-lfs
64-
uses: actions/cache@v4
64+
uses: actions/cache/restore@v4
6565
with:
66+
enableCrossOsArchive: true
6667
path: 'lfs_data_cache/lfs_data'
6768
key: lfs-data-${{env.lfs_data_cache_sha}}-${{inputs.cache_postfix}}
6869

@@ -80,13 +81,11 @@ runs:
8081
repository: ${{ inputs.repository }}
8182
ref: ${{env.lfs_data_cache_sha}}
8283
path: 'lfs_data_cache/lfs_data'
83-
fetch-depth: 0
84+
fetch-depth: 1
8485
lfs: true
8586

8687
- name: Upload LFS artifact
87-
if: |
88-
steps.cache-lfs.outputs.cache-hit != 'true' &&
89-
inputs.type == 'producer'
88+
if: inputs.type == 'producer'
9089
uses: actions/upload-artifact@v4
9190
with:
9291
name: lfs-data-${{inputs.cache_postfix}}
@@ -105,6 +104,14 @@ runs:
105104
name: lfs-data-${{inputs.cache_postfix}}
106105
path: 'lfs_data_cache/lfs_data'
107106

107+
- name: Reinit the git repository
108+
if: |
109+
steps.cache-lfs.outputs.cache-hit != 'true' &&
110+
inputs.type == 'consumer'
111+
working-directory: ${{github.workspace}}/lfs_data_cache/lfs_data
112+
shell: bash
113+
run: git init .
114+
108115
- name: Checkout LFS data (last resort)
109116
if: |
110117
steps.cache-lfs.outputs.cache-hit != 'true' &&
@@ -115,9 +122,20 @@ runs:
115122
repository: ${{ inputs.repository }}
116123
ref: ${{env.lfs_data_cache_sha}}
117124
path: 'lfs_data_cache/lfs_data'
118-
fetch-depth: 0
125+
fetch-depth: 1
119126
lfs: true
120127

128+
- name: Save LFS data cache
129+
if: |
130+
steps.cache-lfs.outputs.cache-hit != 'true' &&
131+
inputs.type == 'producer'
132+
id: cache-lfs-save
133+
uses: actions/cache/save@v4
134+
with:
135+
enableCrossOsArchive: true
136+
path: 'lfs_data_cache/lfs_data'
137+
key: lfs-data-${{env.lfs_data_cache_sha}}-${{inputs.cache_postfix}}
138+
121139
- name: Setup LFS data
122140
working-directory: ${{github.workspace}}
123141
shell: bash

0 commit comments

Comments
 (0)