Skip to content

Commit e07e0c7

Browse files
committed
Prune container images on self-hosted runners
1 parent 38d1b5e commit e07e0c7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.github/workflows/container-prune.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (C) 2021 Intel Corporation
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
5+
6+
# https://docs.docker.com/config/pruning/
7+
name: prune container images on self-hosted runners
8+
9+
on:
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- '.github/workflows/container-prune.yml'
15+
16+
# https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#scheduled-events-schedule
17+
schedule:
18+
# UTC time of midnight in Pacific Standard Time
19+
- cron: '0 8 * * *'
20+
21+
workflow_dispatch:
22+
23+
jobs:
24+
build:
25+
runs-on:
26+
- self-hosted
27+
- linux
28+
- x64
29+
- container
30+
31+
steps:
32+
# https://pkg.go.dev/time#ParseDuration
33+
- name: prune stopped containers, unused networks, unused untagged images, and build cache older than a day
34+
run: docker system prune --force --filter 'until=24h'
35+
36+
- name: prune unused tagged images older than a week
37+
run: docker system prune --force --all --filter 'until=168h'

0 commit comments

Comments
 (0)