Skip to content

Commit ae46c73

Browse files
committed
chore(workflow): add cron for clean docker cache
1 parent 703fada commit ae46c73

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Clean Docker Cache
2+
3+
on:
4+
schedule:
5+
# 每15天凌晨0点运行一次
6+
- cron: '0 0 */15 * *'
7+
8+
jobs:
9+
cleanup:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Connect server to clean docker cache
13+
uses: appleboy/ssh-action@master
14+
with:
15+
host: ${{ secrets.SSH_HOST }}
16+
username: ${{ secrets.SSH_USER }}
17+
key: ${{ secrets.SSH_PRIVATE_KEY }}
18+
script: |
19+
echo "🧹 Starting Docker system prune..."
20+
docker system prune -f
21+
echo "✅ Docker cache cleaned successfully"

.github/workflows/deploy.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
host: ${{ secrets.SSH_HOST }}
1818
username: ${{ secrets.SSH_USER }}
1919
key: ${{ secrets.SSH_PRIVATE_KEY }}
20-
command_timeout: 20m
20+
# 无缓存时,构建大约需要 10min+,8 次拉取重试约 8min+
21+
command_timeout: 30m
2122
script: |
2223
cd ${{ secrets.BLOG_PATH_REMOTE }}
2324
MAX_RETRIES=8
@@ -30,9 +31,6 @@ jobs:
3031
docker stop blog || true
3132
docker rm blog || true
3233
docker rmi nextjs || true
33-
34-
echo "🗑️ Clearing docker cache"
35-
docker system prune -f
3634
docker build -t nextjs .
3735
docker compose up -d
3836
exit 0

0 commit comments

Comments
 (0)