Skip to content

Commit a96d646

Browse files
committed
chore: always cache actions regardless of failure
1 parent 4bb5d9d commit a96d646

File tree

4 files changed

+57
-13
lines changed

4 files changed

+57
-13
lines changed

.github/actions/setup/action.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ runs:
99
with:
1010
node-version-file: .nvmrc
1111

12-
- name: Cache dependencies
12+
- name: Restore dependencies
1313
id: yarn-cache
14-
uses: actions/cache@v4
14+
uses: actions/cache/restore@v4
1515
with:
1616
path: |
1717
**/node_modules
@@ -25,3 +25,12 @@ runs:
2525
if: steps.yarn-cache.outputs.cache-hit != 'true'
2626
run: yarn install --immutable
2727
shell: bash
28+
29+
- name: Cache dependencies
30+
if: steps.yarn-cache.outputs.cache-hit != 'true'
31+
uses: actions/cache/save@v4
32+
with:
33+
path: |
34+
**/node_modules
35+
.yarn/install-state.gz
36+
key: ${{ steps.yarn-cache.outputs.cache-primary-key }}

.github/workflows/build-templates.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ jobs:
8888
--example ${{ matrix.language == 'js' && 'expo' || 'vanilla' }} \
8989
--no-local
9090
91-
- name: Cache dependencies of library
91+
- name: Restore dependencies of library
9292
id: library-yarn-cache
93-
uses: actions/cache@v4
93+
uses: actions/cache/restore@v4
9494
with:
9595
path: |
9696
${{ env.work_dir }}/**/node_modules
@@ -107,6 +107,15 @@ jobs:
107107
rm -f example/yarn.lock # Workaround for cached yarn.lock from older version
108108
yarn install --no-immutable
109109
110+
- name: Cache dependencies of library
111+
if: steps.library-yarn-cache.outputs.cache-hit != 'true'
112+
uses: actions/cache/save@v4
113+
with:
114+
path: |
115+
${{ env.work_dir }}/**/node_modules
116+
${{ env.work_dir }}/yarn.lock
117+
key: ${{ steps.library-yarn-cache.outputs.cache-primary-key }}
118+
110119
- name: Use local version of react-native-builder-bob
111120
run: |
112121
cd packages/react-native-builder-bob
@@ -215,10 +224,10 @@ jobs:
215224
run: |
216225
yarn turbo run build:android --cache-dir=".turbo"
217226
218-
- name: Cache cocoapods
227+
- name: Restore cocoapods
219228
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1
220229
id: library-cocoapods-cache
221-
uses: actions/cache@v4
230+
uses: actions/cache/restore@v4
222231
with:
223232
path: |
224233
${{ env.work_dir }}/**/ios/Pods
@@ -237,6 +246,15 @@ jobs:
237246
cd example/ios
238247
pod install
239248
249+
- name: Cache cocoapods
250+
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true'
251+
uses: actions/cache/save@v4
252+
with:
253+
path: |
254+
${{ env.work_dir }}/**/ios/Pods
255+
${{ env.work_dir }}/**/ios/Podfile.lock
256+
key: ${{ steps.library-cocoapods-cache.outputs.cache-primary-key }}
257+
240258
- name: Build example (iOS)
241259
if: env.ios_build == 1
242260
working-directory: ${{ env.work_dir }}

packages/create-react-native-library/templates/common/$.github/actions/setup/action.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ runs:
99
with:
1010
node-version-file: .nvmrc
1111

12-
- name: Cache dependencies
12+
- name: Restore dependencies
1313
id: yarn-cache
14-
uses: actions/cache@v3
14+
uses: actions/cache/restore@v4
1515
with:
1616
path: |
1717
**/node_modules
@@ -25,3 +25,12 @@ runs:
2525
if: steps.yarn-cache.outputs.cache-hit != 'true'
2626
run: yarn install --immutable
2727
shell: bash
28+
29+
- name: Cache dependencies
30+
if: steps.yarn-cache.outputs.cache-hit != 'true'
31+
uses: actions/cache/save@v4
32+
with:
33+
path: |
34+
**/node_modules
35+
.yarn/install-state.gz
36+
key: ${{ steps.yarn-cache.outputs.cache-primary-key }}

packages/create-react-native-library/templates/common/$.github/workflows/ci.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
uses: ./.github/actions/setup
6464

6565
- name: Cache turborepo for Android
66-
uses: actions/cache@v3
66+
uses: actions/cache@v4
6767
with:
6868
path: ${{ env.TURBO_CACHE_DIR }}
6969
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
@@ -92,7 +92,7 @@ jobs:
9292
9393
- name: Cache Gradle
9494
if: env.turbo_cache_hit != 1
95-
uses: actions/cache@v3
95+
uses: actions/cache@v4
9696
with:
9797
path: |
9898
~/.gradle/wrapper
@@ -119,7 +119,7 @@ jobs:
119119
uses: ./.github/actions/setup
120120

121121
- name: Cache turborepo for iOS
122-
uses: actions/cache@v3
122+
uses: actions/cache@v4
123123
with:
124124
path: ${{ env.TURBO_CACHE_DIR }}
125125
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
@@ -134,10 +134,10 @@ jobs:
134134
echo "turbo_cache_hit=1" >> $GITHUB_ENV
135135
fi
136136
137-
- name: Cache cocoapods
137+
- name: Restore cocoapods
138138
if: env.turbo_cache_hit != 1
139139
id: cocoapods-cache
140-
uses: actions/cache@v3
140+
uses: actions/cache/restore@v4
141141
with:
142142
path: |
143143
**/ios/Pods
@@ -153,6 +153,14 @@ jobs:
153153
env:
154154
NO_FLIPPER: 1
155155

156+
- name: Cache cocoapods
157+
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
158+
uses: actions/cache/save@v4
159+
with:
160+
path: |
161+
**/ios/Pods
162+
key: ${{ steps.cocoapods-cache.outputs.cache-key }}
163+
156164
- name: Build example for iOS
157165
run: |
158166
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

0 commit comments

Comments
 (0)