Skip to content

Cleanup

Cleanup #398

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@4f22ef80902ad409ed55a99dc5133cc1250a0d03 # v3.0.0
with:
account: ministryofjustice
image-names: hmpps-probation-integration-services/*
cut-off: 1w
keep-n-most-recent: 1
tag-selection: untagged
token: ${{ secrets.BOT_GITHUB_PACKAGES_TOKEN }}
- name: Delete all images older than a month that aren't currently deployed
uses: snok/container-retention-policy@4f22ef80902ad409ed55a99dc5133cc1250a0d03 # v3.0.0
with:
account: ministryofjustice
image-names: hmpps-probation-integration-services/*
image-tags: "!test !test-prev !preprod !preprod-prev !prod !prod-prev"
cut-off: 30d
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