-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (80 loc) · 2.76 KB
/
ghcr-cleanup.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Delete old ghcr images
on:
schedule:
- cron: "15 1 * * *" # every day at 1:15am
pull_request:
types: [closed]
workflow_dispatch:
jobs:
pull-request-ghcr-cleanup:
if: ${{ github.event_name == 'pull_request' }}
name: Delete images related to closed PR
runs-on: ubuntu-latest
steps:
- name: Delete images related to closed PR (1)
id: run-1
continue-on-error: true
uses: snok/container-retention-policy@v2
with:
image-names: client-application
cut-off: now UTC
account-type: org
org-name: plgd-dev
filter-tags: vnext-pr${{ github.event.pull_request.number }}*
token: ${{ secrets.GHCR_CLEANUP_PAT }}
token-type: pat
- if: ${{ steps.run-1.outcome == 'failure' }}
run: sleep 60
- name: Delete images related to closed PR (2)
id: run-2
if: ${{ steps.run-1.outcome == 'failure' }}
continue-on-error: true
uses: snok/container-retention-policy@v2
with:
image-names: client-application
cut-off: now UTC
account-type: org
org-name: plgd-dev
filter-tags: vnext-pr${{ github.event.pull_request.number }}*
token: ${{ secrets.GHCR_CLEANUP_PAT }}
token-type: pat
- if: ${{ steps.run-2.outcome == 'failure' }}
run: sleep 60
- name: Delete images related to closed PR (3)
if: ${{ steps.run-2.outcome == 'failure' }}
uses: snok/container-retention-policy@v2
with:
image-names: client-application
cut-off: now UTC
account-type: org
org-name: plgd-dev
filter-tags: vnext-pr${{ github.event.pull_request.number }}*
token: ${{ secrets.GHCR_CLEANUP_PAT }}
token-type: pat
nightly-ghcr-cleanup:
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
name: Delete stale or untagged images
runs-on: ubuntu-latest
steps:
- name: Checkout local actions
uses: actions/checkout@v4
- name: Delete stale or untagged images (1)
id: run-1
continue-on-error: true
uses: ./.github/actions/cleanup-stale
with:
token: ${{ secrets.GHCR_CLEANUP_PAT }}
- name: Delete stale or untagged images (2)
id: run-2
if: ${{ steps.run-1.outcome == 'failure' }}
with:
token: ${{ secrets.GHCR_CLEANUP_PAT }}
delay: 60
continue-on-error: true
uses: ./.github/actions/cleanup-stale
- name: Delete stale or untagged images (3)
if: ${{ steps.run-2.outcome == 'failure' }}
uses: ./.github/actions/cleanup-stale
with:
token: ${{ secrets.GHCR_CLEANUP_PAT }}
delay: 60