forked from spidernet-io/spiderpool
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (43 loc) · 1.46 KB
/
ci-image-gc-by-pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Clean Image CI By PR
# cleaner for ghcr image , when PR is closed
env:
ONLINE_REGISTER: ghcr.io
on:
pull_request:
types: [closed]
permissions: write-all
jobs:
purge-image:
name: Delete image from ghcr.io
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: spiderpool-agent
- name: spiderpool-controller
steps:
# commit sha is used for image tag
- name: Getting image tag
id: tag
run: |
if [ ${{ github.event.pull_request.head.sha }} != "" ]; then
echo "tag=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
else
echo "tag=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Delete CI image
uses: vlaurin/[email protected]
with:
token: ${{ secrets.WELAN_PAT }}
organization: ${{ github.repository_owner }}
container: ${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci
# Dry-run first, then change to `false`
dry-run: false
# Minimum age in days of a version before it is pruned. Defaults to 0 which matches all versions of a container
older-than: 0
# Count of most recent, matching containers to exclude from pruning
keep-last: 0
# untagged versions should be pruned
untagged: true
# if no tag-regex , all tag will be pruned
tag-regex: "${{ env.tag }}"