Skip to content

Commit 6f44336

Browse files
authored
Merge pull request #1593 from ychin/ci-always-save-library-cache
CI: Always upload package cache even if overall build fails
2 parents 6779b85 + e336692 commit 6f44336

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/actions/universal-package/action.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ runs:
6060
6161
echo '::endgroup::'
6262
63-
- name: Cache keg
64-
id: cache-keg
65-
uses: actions/cache@v4
63+
- name: Restore keg cache
64+
id: cache-keg-restore
65+
uses: actions/cache/restore@v4
6666
with:
6767
path: ${{ steps.setup-formula.outputs.brew_prefix }}/Cellar/${{ inputs.formula }}
6868
key: ${{ inputs.formula }}-homebrew-cache-custom-unified-prefix${{ steps.setup-formula.outputs.brew_prefix }}-xcode${{ steps.setup-formula.outputs.xcode_version }}-${{ hashFiles(format('{0}.rb', inputs.formula)) }}
6969

7070
- name: Install formula
71+
id: install-formula
7172
shell: bash
7273
run: |
7374
echo '::group::Install formula'
@@ -100,3 +101,16 @@ runs:
100101
done
101102
102103
echo '::endgroup::'
104+
105+
- name: Save keg cache
106+
id: cache-keg-save
107+
uses: actions/cache/save@v4
108+
# We always save the generated artifact even if the whole run
109+
# fails due to other issues. This helps debugging build
110+
# failure issues faster if the cache doesn't already exist as
111+
# we want subsequent runs to not have to re-generate this
112+
# artifact again.
113+
if: always() && steps.cache-keg-restore.outputs.cache-hit != 'true' && steps.install-formula.conclusion == 'success'
114+
with:
115+
path: ${{ steps.setup-formula.outputs.brew_prefix }}/Cellar/${{ inputs.formula }}
116+
key: ${{ steps.cache-keg-restore.outputs.cache-primary-key }}

0 commit comments

Comments
 (0)