generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (47 loc) · 1.89 KB
/
cleanup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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