Skip to content

Commit

Permalink
cleanup image caches
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario-SO committed Dec 19, 2024
1 parent 0632587 commit 543bcff
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/clean_caches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: cleanup caches
on:
pull_request:
types:
- closed
workflow_dispatch: # Adding manual trigger option

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup all caches
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
# For pull request events, clean specific PR branch caches
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Cleaning caches for PR branch: $BRANCH"
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
else
# For manual dispatch, clean all caches
echo "Cleaning all repository caches"
cacheKeysForPR=$(gh cache list --limit 100 --json id --jq '.[].id')
fi
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh cache delete $cacheKey --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
2 changes: 1 addition & 1 deletion docker-compose.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ services:
volumes:
- mongodb_data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_DATABASE: streameth-staging
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/db-password
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
Expand Down

0 comments on commit 543bcff

Please sign in to comment.