Skip to content

Clean orphaned workflow runs #3

Clean orphaned workflow runs

Clean orphaned workflow runs #3

name: Clean orphaned workflow runs
# GitHub keeps workflow identities in the Actions sidebar after a temporary
# workflow file is removed. Once every run for that orphan is deleted, GitHub
# can drop the stale workflow entry too.
on:
schedule:
# Daily at 06:00 UTC.
- cron: "0 6 * * *"
push:
branches: [main]
paths:
# The first promotion to main performs the initial backlog cleanup without
# exposing a branch-selectable manual trigger with actions:write.
- ".github/workflows/cleanup-orphaned-workflows.yml"
- "scripts/ci/cleanup-orphaned-workflows.mjs"
permissions:
actions: write # Required to delete orphaned workflow runs through the Actions API.
contents: read
concurrency:
group: cleanup-orphaned-workflows
cancel-in-progress: false
jobs:
cleanup:
name: Delete orphaned workflow runs
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout trusted default-branch code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: 1.3.14
- name: Remove stale workflow histories
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bun scripts/ci/cleanup-orphaned-workflows.mjs