Skip to content

Commit 0b6169f

Browse files
committed
Have dockerhub cleanup use same logic as ghcr cleanup
1 parent 0dd2878 commit 0b6169f

File tree

7 files changed

+619
-613
lines changed

7 files changed

+619
-613
lines changed

.github/workflows/cleanup.yml

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,79 @@
1-
name: Delete old DockerHub tags
1+
name: Cleanup old container images
22
on:
33
workflow_dispatch:
4+
inputs:
5+
image:
6+
description: 'Single image to clean (leave empty for all images)'
7+
required: false
8+
type: string
49
schedule:
510
- cron: "0 13 * * 0" # Every Sunday at 1PM UTC (9AM EST)
611
jobs:
12+
find-images:
13+
runs-on: ubuntu-24.04
14+
outputs:
15+
images: ${{ steps.set-matrix.outputs.images }}
16+
steps:
17+
- uses: 'actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8' # v6
18+
19+
- name: Generate matrix
20+
id: set-matrix
21+
run: |
22+
if [ -n "${{ inputs.image }}" ]; then
23+
# Single image specified
24+
images=$(echo '["${{ inputs.image }}"]')
25+
else
26+
# Find all images
27+
images=$(find images -maxdepth 2 -mindepth 2 -type f -name "Dockerfile" | while read dockerfile; do
28+
image_name=$(basename $(dirname "$dockerfile"))
29+
echo "\"$image_name\""
30+
done | jq -s -c .)
31+
fi
32+
# debug
33+
echo "Images to process:"
34+
echo "$images" | jq .
35+
36+
echo "images=$images" >> $GITHUB_OUTPUT
37+
38+
clean-dockerhub:
39+
name: "DockerHub: ${{ matrix.name }}"
40+
runs-on: ubuntu-24.04
41+
needs: [find-images]
42+
permissions:
43+
contents: read
44+
strategy:
45+
matrix:
46+
name: ${{ fromJson(needs.find-images.outputs.images) }}
47+
# be nice to the dockerhub/ghcr API, only run 1 job at a time
48+
max-parallel: 1
49+
fail-fast: false
50+
steps:
51+
- uses: 'actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8' # v6
52+
- name: "Cleanup islandora/${{ matrix.name }}"
53+
run: ./ci/cleanup-images.sh --registry dockerhub
54+
env:
55+
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
56+
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
57+
DOCKERHUB_REPOSITORY: ${{ matrix.name }}
58+
759
clean-ghcr:
60+
name: "GHCR: ${{ matrix.name }}"
861
runs-on: ubuntu-24.04
62+
needs: [find-images]
963
permissions:
1064
contents: read
1165
packages: write
1266
strategy:
1367
matrix:
14-
package:
15-
- alpaca
16-
- base
17-
- blazegraph
18-
- cantaloupe
19-
- crayfish
20-
- crayfits
21-
- drupal
22-
- fcrepo6
23-
- fits
24-
- handle
25-
- homarus
26-
- houdini
27-
- hypercube
28-
- imagemagick
29-
- java
30-
- leptonica
31-
- mariadb
32-
- milliner
33-
- nginx
34-
- postgresql
35-
- riprap
36-
- scyllaridae
37-
- solr
38-
- test
39-
- tomcat
40-
- transkribus
68+
name: ${{ fromJson(needs.find-images.outputs.images) }}
69+
# be nice to the dockerhub/ghcr API, only run 1 job at a time
70+
max-parallel: 1
71+
fail-fast: false
4172
steps:
4273
- uses: 'actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8' # v6
43-
- run: ./ci/cleanup-ghcr.sh
74+
- name: "Cleanup ghcr.io/islandora-devops/${{ matrix.name }}"
75+
run: ./ci/cleanup-images.sh --registry ghcr
4476
env:
4577
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4678
GITHUB_ORG: islandora-devops
47-
PACKAGE_NAME: ${{ matrix.package }}
48-
DRY_RUN: false
79+
PACKAGE_NAME: ${{ matrix.name }}

buildSrc/build.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ gradlePlugin {
3939
description = "Main gradle plugin for the Islandora Isle project"
4040
tags.set(listOf("isle"))
4141
}
42-
create("IsleDockerHub") {
43-
id = "io.github.nigelgbanks.IsleDockerHub"
44-
implementationClass = "plugins.DockerHubPlugin"
45-
displayName = "IsleDockerHub"
46-
description = "Tasks for managing DockerHub tags, etc."
47-
tags.set(listOf("isle"))
48-
}
4942
create("IsleReports") {
5043
id = "io.github.nigelgbanks.IsleReports"
5144
implementationClass = "plugins.ReportsPlugin"

0 commit comments

Comments
 (0)