Skip to content

Cleanup GitHub Actions Cache #40

Cleanup GitHub Actions Cache

Cleanup GitHub Actions Cache #40

name: Cleanup GitHub Actions Cache
on:
schedule:
# 00:00 Europe/Moscow every 3rd day of the month (21:00 UTC)
- cron: "0 21 */3 * *"
workflow_dispatch:
inputs:
dry_run:
description: Preview cache cleanup without deleting anything
required: false
type: boolean
default: true
last_accessed_days:
description: Delete entries if last_accessed_at is older than this many days
required: false
type: number
default: 1
created_days:
description: Delete entries if last_accessed_at is missing and created_at is older than this many days
required: false
type: number
default: 3
concurrency:
group: github-cleanup
cancel-in-progress: true
permissions: { }
jobs:
cleanup-cache:
name: Delete caches
if: github.repository == 'ton-blockchain/acton'
runs-on: ubicloud-standard-2-ubuntu-2204
permissions:
actions: write
contents: read
env:
XTASK_DRY_RUN: ${{ inputs.dry_run }}
XTASK_LAST_ACCESSED_DAYS: ${{ inputs.last_accessed_days }}
XTASK_CREATED_DAYS: ${{ inputs.created_days }}
steps:
- name: Check out Acton repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install
- name: Run GitHub cache cleanup xtask
env:
GH_TOKEN: ${{ github.token }}
# language=Bash
run: |
args=(
run -p xtask -- github-cleanup
)
if [[ -n "${XTASK_LAST_ACCESSED_DAYS}" ]]; then
args+=(--last-accessed-days "${XTASK_LAST_ACCESSED_DAYS}")
fi
if [[ -n "${XTASK_CREATED_DAYS}" ]]; then
args+=(--created-days "${XTASK_CREATED_DAYS}")
fi
if [[ "${XTASK_DRY_RUN}" == 'true' ]]; then
args+=(--dry-run)
fi
cargo "${args[@]}"