Skip to content

cleanup

cleanup #49

Workflow file for this run

name: cleanup
on:
# Weekly cleanup
schedule:
- cron: "30 4 * * 3"
# Manual cleanup
workflow_dispatch:
jobs:
ghcr:
runs-on: ubuntu-latest
steps:
- name: Get repository name
run: |
REPOSITORY_NAME="${{ github.repository }}"
REPOSITORY_NAME="${REPOSITORY_NAME##*/}"
echo "Repository name is: $REPOSITORY_NAME"
echo "REPOSITORY_NAME=$REPOSITORY_NAME" >> $GITHUB_ENV
- name: Delete untagged images
uses: Chizkiyahu/delete-untagged-ghcr-action@v4
with:
token: ${{ secrets.GHCR_ACCESS_TOKEN }}
owner_type: user
package_name: ${{ env.REPOSITORY_NAME }}
untagged_only: true
docker:
runs-on: ubuntu-latest
steps:
- name: Get repository name
run: |
REPOSITORY_NAME="${{ github.repository }}"
REPOSITORY_NAME="${REPOSITORY_NAME##*/}"
echo "Repository name is: $REPOSITORY_NAME"
echo "REPOSITORY_NAME=$REPOSITORY_NAME" >> $GITHUB_ENV
- name: Download regctl
run: |
curl -sSL https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 -o regctl
chmod +x ./regctl
- name: Registry login
run: |
./regctl registry login docker.io -u "${{ vars.DOCKER_IO_USER }}" -p "${{ secrets.DOCKER_IO_ACCESS_TOKEN }}"
- name: Delete untagged images
run: |
./regctl artifact list "docker.io/${{ vars.DOCKER_IO_USER }}/${{ env.REPOSITORY_NAME }}"" --format json | \
jq -r '.[] | select(.tags == null or .tags | length == 0) | .digest' | \
while read digest; do
echo "Deleting untagged digest: $digest"
./regctl manifest rm "docker.io/${{ vars.DOCKER_IO_USER }}/${{ env.REPOSITORY_NAME }}@$digest"
done