Skip to content

Commit

Permalink
ci: using cache and move remove cache on another workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Dec 20, 2024
1 parent cc136cd commit 62e7270
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 54 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/delete_old_caches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Delete old caches

on:
schedule:
- cron: '0 0 * * *'
delete:
branches-ignore:
- master

permissions:
actions: write

jobs:
delete_cache:
runs-on: ubuntu-latest
steps:
- name: Clear cache
uses: actions/github-script@v7
with:
script: |
console.log("About to clear")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
if (cache.ref != 'refs/heads/master') {
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
}
console.log("Clear completed")
28 changes: 1 addition & 27 deletions .github/workflows/development_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
env:
JAVA_VERSION: 21

permissions:
actions: write

jobs:
test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -65,27 +62,4 @@ jobs:
- name: Start services
run: docker compose up -d --build --wait
- name: Stop services
run: docker compose down

clear-cache:
runs-on: ubuntu-latest
needs: [ test-compose ]
steps:
- name: Clear cache
uses: actions/github-script@v7
with:
script: |
console.log("About to clear")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
console.log("Clear completed")
run: docker compose down
28 changes: 1 addition & 27 deletions .github/workflows/release_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,4 @@ jobs:
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag ${{ env.V-VERSION }}
git push origin ${{ env.V-VERSION }}
clear-cache:
permissions:
actions: write

runs-on: ubuntu-latest
needs: [ push-tag ]
steps:
- name: Clear cache
uses: actions/github-script@v7
with:
script: |
console.log("About to clear")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
console.log("Clear completed")
git push origin ${{ env.V-VERSION }}

0 comments on commit 62e7270

Please sign in to comment.