Skip to content

Commit 4ccf251

Browse files
authored
ci: Store build output as artifacts instead of cache (#13487)
This PR changes it so that the build output is kept as an artifact, not a cache. This way, this should never be lost on us. We keep the NX cache as before. I chose a retention period of 7 days, which means that after 7 days you could no longer re-run a workflow partially. IMHO that's a reasonable start, we can adjust this if needed.
1 parent 3a1417f commit 4ccf251

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

.github/actions/restore-cache/action.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ runs:
1111
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
1212
key: ${{ env.DEPENDENCY_CACHE_KEY }}
1313

14-
- name: Check build cache
15-
uses: actions/cache/restore@v4
16-
id: build-cache
14+
- name: Restore build artifacts
15+
uses: actions/download-artifact@v4
1716
with:
18-
path: ${{ env.CACHED_BUILD_PATHS }}
19-
key: ${{ env.BUILD_CACHE_KEY }}
17+
name: build-output
2018

2119
- name: Check if caches are restored
2220
uses: actions/github-script@v6
23-
if: steps.dep-cache.outputs.cache-hit != 'true' || steps.build-cache.outputs.cache-hit != 'true'
21+
if: steps.dep-cache.outputs.cache-hit != 'true'
2422
with:
25-
script: core.setFailed('Dependency or build cache could not be restored - please re-run ALL jobs.')
23+
script: core.setFailed('Dependency cache could not be restored - please re-run ALL jobs.')

.github/workflows/build.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ env:
4848
${{ github.workspace }}/packages/utils/cjs
4949
${{ github.workspace }}/packages/utils/esm
5050
51-
BUILD_CACHE_KEY: build-cache-${{ github.event.inputs.commit || github.sha }}
5251
BUILD_CACHE_TARBALL_KEY: tarball-${{ github.event.inputs.commit || github.sha }}
5352

5453
# GH will use the first restore-key it finds that matches
@@ -160,13 +159,6 @@ jobs:
160159
base: ${{ github.event.pull_request.base.sha }}
161160
head: ${{ env.HEAD_COMMIT }}
162161

163-
- name: Check build cache
164-
uses: actions/cache@v4
165-
id: cache_built_packages
166-
with:
167-
path: ${{ env.CACHED_BUILD_PATHS }}
168-
key: ${{ env.BUILD_CACHE_KEY }}
169-
170162
- name: NX cache
171163
uses: actions/cache@v4
172164
# Disable cache when:
@@ -188,6 +180,15 @@ jobs:
188180
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
189181
run: yarn build
190182

183+
- name: Upload build artifacts
184+
uses: actions/upload-artifact@v4
185+
with:
186+
name: build-output
187+
path: ${{ env.CACHED_BUILD_PATHS }}
188+
retention-days: 7
189+
compression-level: 6
190+
overwrite: true
191+
191192
outputs:
192193
dependency_cache_key: ${{ steps.install_dependencies.outputs.cache_key }}
193194
changed_node_integration: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry-internal/node-integration-tests') }}

0 commit comments

Comments
 (0)