Skip to content

Delete old container images #3939

Delete old container images

Delete old container images #3939

name: Delete old container images
on:
schedule:
- cron: "15 */12 * * *" # run hourly
push:
branches:
- "*"
- "!main" # excludes main
paths:
- "github-actions/cleanup-packages/**"
- ".github/workflows/image-retention.yaml"
pull_request:
paths:
- "github-actions/cleanup-packages/**"
- ".github/workflows/image-retention.yaml"
workflow_dispatch:
jobs:
cleanup-packages:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ./github-actions/cleanup-packages/go.mod
cache-dependency-path: ./github-actions/cleanup-packages/go.sum
- name: Verify dependencies
run: go mod verify
working-directory: ./github-actions/cleanup-packages/
- name: Build
run: go build -v ./...
working-directory: ./github-actions/cleanup-packages/
- name: Run go vet
run: go vet ./...
working-directory: ./github-actions/cleanup-packages/
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
working-directory: ./github-actions/cleanup-packages/
- name: Run staticcheck
run: staticcheck ./...
working-directory: ./github-actions/cleanup-packages/
- name: Install golint
run: go install golang.org/x/lint/golint@latest
working-directory: ./github-actions/cleanup-packages/
- name: Run golint
run: golint ./...
working-directory: ./github-actions/cleanup-packages/
- name: Run tests
run: go test -race -vet=off ./...
working-directory: ./github-actions/cleanup-packages/
- name: Delete Versions
if: github.ref == 'refs/heads/main'
run: go run ./cmd/cleanup/main.go
env:
PAT_CONTAINER_REGISTRY: ${{ secrets.PAT_CONTAINER_REGISTRY }}
working-directory: ./github-actions/cleanup-packages/