Skip to content

Cleanup

Cleanup #315

Workflow file for this run

name: Cleanup
# Delete old reports from GitHub Pages, and delete unused images from GitHub Container Registry
# Note: deleted images are still retained by GitHub for 30 days. To recover them, see: https://docs.github.com/en/rest/packages#restore-package-version-for-an-organization
on:
schedule:
- cron: "30 5 * * MON-FRI" # Every weekday at 05:30 UTC
workflow_dispatch:
jobs:
delete-images:
runs-on: ubuntu-latest
steps:
- name: Delete untagged images older than 1 week
uses: snok/container-retention-policy@b56f4ff7539c1f94f01e5dc726671cd619aa8072 # v2.2.1
with:
account-type: org
org-name: ministryofjustice
image-names: hmpps-probation-integration-services/*
cut-off: A week ago UTC
keep-at-least: 1
untagged-only: true
token: ${{ secrets.BOT_GITHUB_PACKAGES_TOKEN }}
- name: Delete all images older than a month that aren't currently deployed
uses: snok/container-retention-policy@b56f4ff7539c1f94f01e5dc726671cd619aa8072 # v2.2.1
with:
account-type: org
org-name: ministryofjustice
image-names: hmpps-probation-integration-services/*
cut-off: 1 month ago UTC
skip-tags: test,test-prev,preprod,preprod-prev,prod,prod-prev
token: ${{ secrets.BOT_GITHUB_PACKAGES_TOKEN }}
delete-reports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 0
- name: Delete Playwright reports older than 1 week
run: |
wget https://raw.githubusercontent.com/newren/git-filter-repo/main/git-filter-repo
git pull origin gh-pages
python3 git-filter-repo \
--path 'tech-docs' \
--path 'tech-docs-drafts' \
--path 'schema-spy-report' \
--refs gh-pages \
--force
git gc --prune=now
git push origin gh-pages --force