|
1 | | -name: Delete old DockerHub tags |
| 1 | +name: Cleanup old container images |
2 | 2 | on: |
3 | 3 | workflow_dispatch: |
| 4 | + inputs: |
| 5 | + image: |
| 6 | + description: 'Single image to clean (leave empty for all images)' |
| 7 | + required: false |
| 8 | + type: string |
4 | 9 | schedule: |
5 | 10 | - cron: "0 13 * * 0" # Every Sunday at 1PM UTC (9AM EST) |
6 | 11 | 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 | + |
7 | 59 | clean-ghcr: |
| 60 | + name: "GHCR: ${{ matrix.name }}" |
8 | 61 | runs-on: ubuntu-24.04 |
| 62 | + needs: [find-images] |
9 | 63 | permissions: |
10 | 64 | contents: read |
11 | 65 | packages: write |
12 | 66 | strategy: |
13 | 67 | 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 |
41 | 72 | steps: |
42 | 73 | - 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 |
44 | 76 | env: |
45 | 77 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
46 | 78 | GITHUB_ORG: islandora-devops |
47 | | - PACKAGE_NAME: ${{ matrix.package }} |
48 | | - DRY_RUN: false |
| 79 | + PACKAGE_NAME: ${{ matrix.name }} |
0 commit comments