Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-labs committed Jun 19, 2024
1 parent 4c46ebc commit 28aa446
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/cleanup_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: cleanup caches by a branch

Check failure

Code scanning / Scorecard

Token-Permissions High

score is 0: no topLevel permission defined
Click Remediation section below to solve this issue
on:
pull_request:
# types:
# - closed

jobs:
cleanup:
runs-on: intellabs-01
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
24 changes: 1 addition & 23 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
---
name: test-build
on:
# Triggers the workflow on push or pull request events but
# only for the main branch
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
Expand Down Expand Up @@ -39,25 +35,7 @@ jobs:
key: ${{ runner.os }}-build-${{ github.run_number }}
#${{ github.ref }}
#-${{ hashFiles('.') }}
# restore-key: ${{ runner.os }}-build-${{ github.run_number }}
- name: Cleanup Cache
run: |
gh extension install actions/gh-actions-cache
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
for cacheKey in $cacheKeysForPR
do
echo $cacheKey
done
echo gh actions-cache delete $CACHE_ENTRY -R $REPO -B $BRANCH --confirm
gh actions-cache delete $CACHE_ENTRY -R $REPO -B $BRANCH --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: intellabs/scenario_execution
#${{ github.repository }}
CACHE_ENTRY: ${{ runner.os }}-build-${{ github.run_number }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
restore-keys: ${{ runner.os }}-build-${{ github.run_number }}
run-tests:
needs: [build-and-cache]
runs-on: intellabs-01
Expand Down

0 comments on commit 28aa446

Please sign in to comment.