Skip to content

Commit 3569830

Browse files
authored
Merge pull request #1477 from xael-fry/github-actions-configuration
GitHub actions configuration
2 parents 15ae54d + b1fafd7 commit 3569830

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

.github/workflows/build-test.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
name: Pull Requests
1+
name: Check
22

33
on:
4+
pull_request: # Check Pull Requests
5+
46
push:
5-
pull_request:
7+
branches:
8+
- master # Check branch after merge
69

710
concurrency:
811
# Only run once for latest commit per ref and cancel other (previous) runs.

.github/workflows/delete-caches.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Delete Caches
2+
on:
3+
schedule:
4+
- cron: "0 */4 * * *" # Every 4th hour
5+
6+
concurrency:
7+
# Only run once and cancel other (previous) runs.
8+
group: delete-caches
9+
cancel-in-progress: true
10+
11+
permissions:
12+
actions: write # this permission is needed to delete cache
13+
14+
jobs:
15+
delete-public-local-caches:
16+
name: Delete unneeded caches
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- run: |
21+
gh cache list --limit 500 --order asc --sort last_accessed_at | grep 'play-published-local' > caches.txt || true
22+
echo "Found $(wc -l < caches.txt | xargs) published local cache entries"
23+
24+
current_time=$(date -u +%s)
25+
expiration_time=$((current_time - 7200)) # 2 hour ago
26+
27+
echo "Current time is $(date -d @$current_time)"
28+
echo "All entries hadn't been use from $(date -d @$expiration_time) will be delete"
29+
30+
while IFS=$'\t' read -r id name size created_at last_accessed_at; do
31+
accessedTimestamp=$(date -u -d "$last_accessed_at" +%s)
32+
# Uncomment to check on Mac OS
33+
# accessedTimestamp=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$last_accessed_at" +%s)
34+
if [ "$accessedTimestamp" -lt "$expiration_time" ]; then
35+
echo "Delete $id $name ($last_accessed_at)"
36+
gh cache delete $id
37+
fi
38+
done < caches.txt
39+
rm -rf caches.txt
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+

0 commit comments

Comments
 (0)