diff --git a/.github/workflows/maintenance.yml b/.github/workflows/maintenance.yml index 8df6667f..925f1f45 100644 --- a/.github/workflows/maintenance.yml +++ b/.github/workflows/maintenance.yml @@ -40,7 +40,7 @@ jobs: uses: actions/checkout@v2.3.4 - name: Run deletion script 🗑 - run: ./delete_ghcr_dangling_images.sh ${{ matrix.container }} + run: ./delete_ghcr_dangling_images.sh lowlighter ${{ matrix.container }} working-directory: ./.github/workflows/maintenance env: - GITHUB_TOKEN: ${{ secrets.GHCR_BOT_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} #${{ secrets.GHCR_BOT_TOKEN }} diff --git a/.github/workflows/maintenance/delete_ghcr_dangling_images.sh b/.github/workflows/maintenance/delete_ghcr_dangling_images.sh index c77bc07a..4b6ea32b 100755 --- a/.github/workflows/maintenance/delete_ghcr_dangling_images.sh +++ b/.github/workflows/maintenance/delete_ghcr_dangling_images.sh @@ -5,12 +5,13 @@ set -e # You need to be logged to 'gh' first. # package_name syntax. i.e: jellyfin-vue -container="$1" +owner="$1" +container="$2" temp_file="ghcr_prune.ids" rm -rf $temp_file echo "Fetching dangling images from GHCR..." -gh api /user/packages/container/${container}/versions --paginate > $temp_file +gh api /users/${owner}/packages/container/${container}/versions --paginate > $temp_file ids_to_delete=$(cat "$temp_file" | jq -r '.[] | select(.metadata.container.tags==[]) | .id') @@ -25,7 +26,7 @@ while read -r line; do id="$line" echo "Processing image $id" ## Workaround for https://github.com/cli/cli/issues/4286 and https://github.com/cli/cli/issues/3937 - echo -n | gh api --method DELETE /user/packages/container/${container}/versions/${id} --input - + echo -n | gh api --method DELETE /users/${owner}/packages/container/${container}/versions/${id} --input - echo Dangling image with ID $id deleted successfully done <<< $ids_to_delete