Skip to content

Commit 7d45bbf

Browse files
feat remove github action caches
1 parent 92782c1 commit 7d45bbf

File tree

4 files changed

+72
-6
lines changed

4 files changed

+72
-6
lines changed

.github/workflows/backend-ci.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
contents: read
2121
packages: write
2222
security-events: write
23+
actions: write
2324

2425
steps:
2526
# 1. Checkout code
@@ -53,15 +54,46 @@ jobs:
5354
restore-keys: |
5455
${{ runner.os }}-sbt-
5556
56-
# 5. Build (compile & stage)
57+
# 5. Clean old caches (keep only 15 most recent)
58+
- name: Clean old caches
59+
# if: github.ref == 'refs/heads/main'
60+
uses: actions/github-script@v7
61+
with:
62+
script: |
63+
const caches = await github.rest.actions.getActionsCacheList({
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
per_page: 100,
67+
sort: 'created_at',
68+
direction: 'desc'
69+
});
70+
71+
const cachesToDelete = caches.data.actions_caches.slice(15);
72+
73+
if (cachesToDelete.length === 0) {
74+
console.log('No old caches to delete.');
75+
return;
76+
}
77+
78+
console.log(`Found ${cachesToDelete.length} cache(s) to delete.`);
79+
for (const cache of cachesToDelete) {
80+
console.log(`Deleting cache: ${cache.key} (ID: ${cache.id})`);
81+
await github.rest.actions.deleteActionsCacheById({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
cache_id: cache.id
85+
});
86+
}
87+
88+
# 6. Build (compile & stage)
5789
- name: Build Play Framework App
5890
run: sbt stage
5991

60-
# 6. Run Scalastyle (Static Code Analysis)
92+
# 7. Run Scalastyle (Static Code Analysis)
6193
- name: Run Scalastyle
6294
run: sbt scalastyle
6395

64-
# 7. Run tests with coverage
96+
# 8. Run tests with coverage
6597
- name: Run Scoverage Tests
6698
run: sbt clean coverage test coverageReport coverageAggregate
6799

.github/workflows/frontend-ci.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
contents: read
2121
packages: write
2222
security-events: write
23+
actions: write
2324

2425
steps:
2526
# 1. Checkout & Setup
@@ -33,7 +34,38 @@ jobs:
3334
cache: 'npm'
3435
cache-dependency-path: frontend/package-lock.json
3536

36-
# 2. Install dependencies
37+
# 2. Clean old caches (keep only 15 most recent)
38+
- name: Clean old caches
39+
# if: github.ref == 'refs/heads/main'
40+
uses: actions/github-script@v7
41+
with:
42+
script: |
43+
const caches = await github.rest.actions.getActionsCacheList({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
per_page: 100,
47+
sort: 'created_at',
48+
direction: 'desc'
49+
});
50+
51+
const cachesToDelete = caches.data.actions_caches.slice(15);
52+
53+
if (cachesToDelete.length === 0) {
54+
console.log('No old caches to delete.');
55+
return;
56+
}
57+
58+
console.log(`Found ${cachesToDelete.length} cache(s) to delete.`);
59+
for (const cache of cachesToDelete) {
60+
console.log(`Deleting cache: ${cache.key} (ID: ${cache.id})`);
61+
await github.rest.actions.deleteActionsCacheById({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
cache_id: cache.id
65+
});
66+
}
67+
68+
# 3. Install dependencies
3769
- name: Install dependencies
3870
run: npm ci
3971

@@ -44,13 +76,13 @@ jobs:
4476
npm run format:check || true
4577
npx tsc --noEmit || true
4678
47-
# 4. Run Tests
79+
# 5. Run Tests
4880
- name: Run Unit Tests & Coverage
4981
run: |
5082
npm run test:run
5183
npm run test:coverage
5284
53-
# 5. Build & Deploy
85+
# 6. Build & Deploy
5486
- name: Build & Deploy
5587
run: |
5688
npm run build

backend/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

frontend/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
text

0 commit comments

Comments
 (0)