name: Clean up old workflow runs # Manual only, and dry run by default (#324). # # Gitea 1.27.3 expires a run's logs and artifacts but never the run record # itself, so the Actions list grows without limit and fills with entries whose # logs are already gone. This removes those entries. # # Deliberately not on a schedule. Deleting a run cannot be undone, the list is # an annoyance rather than a problem, and a cron that quietly removes history # should be a decision taken on its own rather than the default that arrives # with the tool. on: workflow_dispatch: inputs: keep_days: description: 'Keep runs newer than this many days' required: false default: '7' apply: description: 'Type true to actually delete. Anything else reports only.' required: false default: 'false' jobs: cleanup: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: '20' # No npm install: the script uses only node's own https module, so there # is nothing to fetch and nothing that can break when a dependency moves. - name: Delete old runs env: # A dedicated secret rather than the automatic per-job token, because # deleting a run may be beyond what that token is allowed to do. If it # turns out to be sufficient, this and the secret can both go. GITEA_ACCESS_TOKEN: ${{ secrets.ACTIONS_CLEANUP_TOKEN }} # Taken from the run's own context so this file carries no hostname # and works unchanged if the instance ever moves — which #313 may yet # make happen. GITEA_HOST: ${{ github.server_url }} GITEA_REPO: ${{ github.repository }} KEEP_DAYS: ${{ github.event.inputs.keep_days }} APPLY: ${{ github.event.inputs.apply }} run: node scripts/cleanup-workflow-runs.js