Skip to content

Commit

Permalink
Merge pull request playframework#1477 from xael-fry/github-actions-co…
Browse files Browse the repository at this point in the history
…nfiguration

GitHub actions configuration
  • Loading branch information
xael-fry authored Mar 3, 2024
2 parents 15ae54d + b1fafd7 commit 3569830
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Pull Requests
name: Check

on:
pull_request: # Check Pull Requests

push:
pull_request:
branches:
- master # Check branch after merge

concurrency:
# Only run once for latest commit per ref and cancel other (previous) runs.
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/delete-caches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Delete Caches
on:
schedule:
- cron: "0 */4 * * *" # Every 4th hour

concurrency:
# Only run once and cancel other (previous) runs.
group: delete-caches
cancel-in-progress: true

permissions:
actions: write # this permission is needed to delete cache

jobs:
delete-public-local-caches:
name: Delete unneeded caches
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
gh cache list --limit 500 --order asc --sort last_accessed_at | grep 'play-published-local' > caches.txt || true
echo "Found $(wc -l < caches.txt | xargs) published local cache entries"
current_time=$(date -u +%s)
expiration_time=$((current_time - 7200)) # 2 hour ago
echo "Current time is $(date -d @$current_time)"
echo "All entries hadn't been use from $(date -d @$expiration_time) will be delete"
while IFS=$'\t' read -r id name size created_at last_accessed_at; do
accessedTimestamp=$(date -u -d "$last_accessed_at" +%s)
# Uncomment to check on Mac OS
# accessedTimestamp=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$last_accessed_at" +%s)
if [ "$accessedTimestamp" -lt "$expiration_time" ]; then
echo "Delete $id $name ($last_accessed_at)"
gh cache delete $id
fi
done < caches.txt
rm -rf caches.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.

0 comments on commit 3569830

Please sign in to comment.