2023-04-26 12:50:31 +02:00
|
|
|
# This workflow runs on certain conditions to check for and potentially
|
|
|
|
# delete container images from the GHCR which no longer have an associated
|
|
|
|
# code branch.
|
|
|
|
# Requires a PAT with the correct scope set in the secrets.
|
|
|
|
#
|
|
|
|
# This workflow will not trigger runs on forked repos.
|
|
|
|
|
2023-11-29 05:07:47 +02:00
|
|
|
name: Docker Cleanup
|
2023-04-26 12:50:31 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types:
|
|
|
|
- "closed"
|
|
|
|
push:
|
|
|
|
paths:
|
|
|
|
- ".github/workflows/docker-cleanup.yml"
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: registry-tags-cleanup
|
|
|
|
cancel-in-progress: false
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cleanup-images:
|
|
|
|
name: Cleanup Stale Images Tags for ${{ matrix.primary-name }}
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- primary-name: "immich-server"
|
|
|
|
- primary-name: "immich-machine-learning"
|
|
|
|
env:
|
|
|
|
# Requires a personal access token with the OAuth scope delete:packages
|
|
|
|
TOKEN: ${{ secrets.PACKAGE_DELETE_TOKEN }}
|
|
|
|
steps:
|
2023-11-18 06:13:36 +02:00
|
|
|
- name: Clean temporary images
|
2023-04-26 12:50:31 +02:00
|
|
|
if: "${{ env.TOKEN != '' }}"
|
2024-07-31 14:48:06 +02:00
|
|
|
uses: stumpylog/image-cleaner-action/ephemeral@v0.8.0
|
2023-04-26 12:50:31 +02:00
|
|
|
with:
|
|
|
|
token: "${{ env.TOKEN }}"
|
|
|
|
owner: "immich-app"
|
|
|
|
is_org: "true"
|
2023-05-15 19:45:03 +02:00
|
|
|
do_delete: "true"
|
2023-04-26 12:50:31 +02:00
|
|
|
package_name: "${{ matrix.primary-name }}"
|
|
|
|
scheme: "pull_request"
|
|
|
|
repo_name: "immich"
|
|
|
|
match_regex: '^pr-(\d+)$|^(\d+)$'
|
|
|
|
|
|
|
|
cleanup-untagged-images:
|
|
|
|
name: Cleanup Untagged Images Tags for ${{ matrix.primary-name }}
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
needs:
|
|
|
|
- cleanup-images
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- primary-name: "immich-server"
|
|
|
|
- primary-name: "immich-machine-learning"
|
|
|
|
- primary-name: "immich-build-cache"
|
|
|
|
env:
|
|
|
|
# Requires a personal access token with the OAuth scope delete:packages
|
|
|
|
TOKEN: ${{ secrets.PACKAGE_DELETE_TOKEN }}
|
|
|
|
steps:
|
2023-11-18 06:13:36 +02:00
|
|
|
- name: Clean untagged images
|
2023-04-26 12:50:31 +02:00
|
|
|
if: "${{ env.TOKEN != '' }}"
|
2024-07-31 14:48:06 +02:00
|
|
|
uses: stumpylog/image-cleaner-action/untagged@v0.8.0
|
2023-04-26 12:50:31 +02:00
|
|
|
with:
|
|
|
|
token: "${{ env.TOKEN }}"
|
|
|
|
owner: "immich-app"
|
2023-05-15 19:45:03 +02:00
|
|
|
do_delete: "true"
|
2023-04-26 12:50:31 +02:00
|
|
|
is_org: "true"
|
|
|
|
package_name: "${{ matrix.primary-name }}"
|