Skip to content

Commit c1ba730

Browse files
committed
chore: enable read-only cache on branches builds
1 parent 7cbf826 commit c1ba730

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,30 @@ jobs:
2222
- uses: actions/setup-node@v4
2323
with:
2424
node-version: '20'
25-
cache: 'yarn'
25+
26+
- name: data
27+
id: data
28+
run: |
29+
echo "YARN_CACHE_DIR=$(yarn cache dir)" >> $GITHUB_OUTPUT
30+
31+
- name: yarn cache
32+
id: yarn-cache-rw
33+
uses: actions/cache@v3
34+
if: github.ref_name == 'main'
35+
with:
36+
key: yarn-${{ hashFiles('yarn.lock') }}
37+
path: ${{ steps.data.outputs.YARN_CACHE_DIR }}
38+
39+
- name: yarn cache
40+
id: yarn-cache-ro
41+
uses: actions/cache/restore@v3
42+
if: github.ref_name != 'main'
43+
with:
44+
key: yarn-${{ hashFiles('yarn.lock') }}
45+
path: ${{ steps.data.outputs.YARN_CACHE_DIR }}
2646

2747
- name: turbo cache
48+
id: turbo-cache-rw
2849
uses: actions/cache@v3
2950
if: github.ref_name == 'main'
3051
with:
@@ -33,6 +54,16 @@ jobs:
3354
restore-keys: |
3455
turbo-
3556
57+
- name: turbo cache
58+
id: turbo-cache-ro
59+
uses: actions/cache/restore@v3
60+
if: github.ref_name != 'main'
61+
with:
62+
path: .turbo
63+
key: turbo-${{ github.sha }}
64+
restore-keys: |
65+
turbo-
66+
3667
- name: build
3768
run: |
3869
yarn install

.github/workflows/pre-release.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
2024
- name: data
2125
id: data
2226
run: |
2327
echo "NPM_TAG=$(echo ${{ github.event.inputs.version }} | cut -d '-' -f2 -s | cut -d '.' -f1 -s)" >> $GITHUB_OUTPUT
28+
echo "YARN_CACHE_DIR=$(yarn cache dir)" >> $GITHUB_OUTPUT
2429
25-
- uses: actions/setup-node@v4
30+
- name: yarn cache
31+
uses: actions/cache/restore@v3
2632
with:
27-
node-version: '20'
28-
cache: 'yarn'
33+
key: yarn-${{ hashFiles('yarn.lock') }}
34+
path: ${{ steps.data.outputs.YARN_CACHE_DIR }}
2935

3036
- name: build
3137
run: |

.github/workflows/release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ jobs:
2020
- uses: actions/setup-node@v4
2121
with:
2222
node-version: '20'
23-
cache: 'yarn'
23+
24+
- name: data
25+
id: data
26+
run: |
27+
echo "YARN_CACHE_DIR=$(yarn cache dir)" >> $GITHUB_OUTPUT
28+
29+
- name: yarn cache
30+
uses: actions/cache/restore@v3
31+
with:
32+
key: yarn-${{ hashFiles('yarn.lock') }}
33+
path: ${{ steps.data.outputs.YARN_CACHE_DIR }}
2434

2535
- name: build
2636
run: |

0 commit comments

Comments
 (0)