Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: souji action #569

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions .github/workflows/cleanup-caches.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: cleanup caches by a branch
name: souji
on:
pull_request:
types:
Expand All @@ -11,30 +11,6 @@ jobs:
permissions:
# https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
actions: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
steps:
- name: Cleanup
env:
BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
MERGE_BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
run: |
gh extension install actions/gh-actions-cache

echo "Fetching list of cache key"
cacheKeysForBranch=$(gh actions-cache list --branch=$BRANCH --limit=100 | cut -f 1 )
cacheKeysForPR=$(gh actions-cache list --branch=$MERGE_BRANCH --limit=100 | cut -f 1 )

## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForBranch
do
gh actions-cache delete $cacheKey --branch=$BRANCH --confirm
done
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey --branch=$MERGE_BRANCH --confirm
done
echo "Done"
uses: 4m-mazi/souji-action@d6224b7c49f3e54c46ef63ed08f4652568269679