Skip to content

Commit 10294dc

Browse files
committed
chore: use env var for cache key
1 parent 65e4f48 commit 10294dc

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ permissions:
1010

1111
jobs:
1212
compile:
13-
# permissions:
14-
# actions: write # this permission is needed to delete cache
15-
permissions: write-all
1613
strategy:
1714
fail-fast: false
1815
runs-on: ubuntu-latest
@@ -32,43 +29,26 @@ jobs:
3229
run: npm ci --ignore-scripts
3330
timeout-minutes: 10
3431

35-
# Get the compilation cache. Decide later what to do
32+
# Setting a global cache which key changes every day
33+
- name: Set Cache Key
34+
run: echo "CACHE_KEY=compile-cache-main-$(date +%Y-%m-%d)" >> "$GITHUB_ENV"
3635
- name: Compile Cache Lookup
3736
# if: ${{ github.event_name == 'pull_request' }}
3837
uses: actions/cache/restore@v4
3938
with:
40-
key: compile-cache-main
41-
path: .nx-server-cache
42-
39+
key: ${{ env.CACHE_KEY }}
40+
path: .nx
4341
- name: Compile
44-
run: |
45-
node ./scripts/nx-cache-server.mjs &
46-
npm run compile
47-
env:
48-
NX_CACHE_SERVER_PATH: .nx-server-cache
49-
NX_CACHE_SERVER_PORT: 3333
50-
NX_SELF_HOSTED_REMOTE_CACHE_SERVER: http://localhost:3333
51-
52-
# For main branch delete cache and save new compilation result
53-
- name: Delete Cache (Push)
54-
# if: ${{ github.event_name == 'push' }}
55-
# run: gh cache delete compile-cache-main
56-
run: |
57-
gh api \
58-
--method DELETE \
59-
-H "Accept: application/vnd.github+json" \
60-
-H "X-GitHub-Api-Version: 2022-11-28" \
61-
/repos/open-telemetry/opentelemetry-js-contrib/actions/caches/compile-cache-main
62-
env:
63-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: npm run compile
6443
- name: Update Cache (Push)
6544
# if: ${{ github.event_name == 'push' }}
6645
uses: actions/cache/save@v4
6746
with:
68-
key: compile-cache-main
69-
path: .nx-server-cache
47+
key: ${{ env.CACHE_KEY }}
48+
path: .nx
7049

71-
# Uplad the file cache for the follwing tasks
50+
# Upload the compilation results as an artifact thta will be available
51+
# only for this runa dn will be deleted in one day.
7252
- name: Upload Build Artifacts
7353
uses: actions/upload-artifact@v4
7454
with:

0 commit comments

Comments
 (0)