Skip to content

acr-housekeeping

acr-housekeeping #242

name: acr-housekeeping
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
permissions: {}
env:
FORCE_COLOR: 3
TERM: xterm
jobs:
purge:
name: 'purge-${{ matrix.repository }}'
runs-on: ubuntu-latest
environment:
name: azure
permissions:
id-token: write
strategy:
fail-fast: false
max-parallel: 2
matrix:
repository:
- adventofcode
- alexa-london-travel-site
- api
- applepayjssample
- costellobot
- dependabot-helper
- home
- signinwithapplesample
- website
steps:
- name: Azure log in
uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Purge old images
shell: pwsh
env:
REPOSITORY: '${{ github.repository_owner }}/${{ matrix.repository }}'
run: |
$purgeCommand = "acr purge --filter '${env:REPOSITORY}:.*' --ago 1d --keep 2 --untagged"
az acr run --cmd $purgeCommand --registry ${env:GITHUB_REPOSITORY_OWNER} /dev/null