Skip to content

ghcr actions

ghcr actions #64

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: ghcr actions
on:
workflow_dispatch:
schedule:
- cron: "21 21 * * *"
jobs:
clean-ghcr:
name: Delete old unused container images
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: downcase REPO name
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/${{ env.REPO }}
- name: Delete 'PR' containers older than a week
uses: snok/[email protected]
with:
image-names: ${{ env.REPO }}
image-tags: "sha-* sha256:* !latest"
cut-off: 1w
account: ${{ github.repository_owner }}
keep-n-most-recent: 1
token: ${{ secrets.GITHUB_TOKEN }}
timestamp-to-use: updated_at