-
Notifications
You must be signed in to change notification settings - Fork 32
106 lines (95 loc) · 3.62 KB
/
live_test.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Test action main branch
on:
workflow_dispatch:
schedule:
- cron: "5 * * * *" # every hour
jobs:
clean:
runs-on: ubuntu-latest
name: Ubuntu with classic personal access token
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch multi-platform package version SHAs
id: multi-arch-digests
run: |
digest=$(docker manifest inspect ghcr.io/snok/container-retention-policy:v3.0.0 | jq -r '.manifests[].digest' | paste -s -d ' ' -)
echo "multi-arch-digests=$digest" >> $GITHUB_OUTPUT
- uses: snok/container-retention-policy@main
name: Delete test-1-* images with a temporal token
with:
account: snok
token: ${{ secrets.GITHUB_TOKEN }}
cut-off: 2h
image-names: container-retention-policy
image-tags: test-* !test-2* !test-3* !test-4* !test-5*
tag-selection: both
timestamp-to-use: created_at
dry-run: false
rust-log: container_retention_policy=debug
skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }}
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: 911530
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- uses: snok/container-retention-policy@main
name: Delete test-2-* images with an Github app token
with:
account: snok
token: ${{ steps.generate-token.outputs.token }}
cut-off: 2h
image-names: container-retention-policy
image-tags: test-* !test-3* !test-4* !test-5*
tag-selection: both
timestamp-to-use: created_at
dry-run: false
rust-log: container_retention_policy=debug
skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }}
- uses: snok/container-retention-policy@main
name: Delete remaining test images with a PAT
with:
account: snok
token: ${{ secrets.PAT }}
cut-off: 2h
image-names: container-retention-policy
image-tags: test-*
tag-selection: both
timestamp-to-use: created_at
dry-run: false
rust-log: container_retention_policy=debug
skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }}
produce:
runs-on: ubuntu-latest
name: Upload more test images
steps:
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build empty images
run: |
for ((i=1; i<=5; i++))
do
randomString=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 10 2>/dev/null || echo RANDOM)
{
echo "FROM alpine as builder"
echo "RUN echo \"$randomString\" > test.txt"
echo "FROM scratch"
echo "COPY --from=builder /test.txt ."
} > Dockerfile
imageName="ghcr.io/snok/container-retention-policy:test-${i}"
docker build -f Dockerfile -t "$imageName" --push .
for ((j=1; j<=3; j++))
do
docker tag "$imageName" "ghcr.io/snok/container-retention-policy:test-${i}-${j}"
docker push "ghcr.io/snok/container-retention-policy:test-${i}-${j}"
done
done