Skip to content

GitHub Action Manage Stale PRs

Chloe Lin [SSW] edited this page Jun 10, 2025 · 1 revision

This GitHub Action helps manage the lifecycle of pull requests by automatically labeling PRs based on age and flagging those that may be suffering from merge debt. It’s part of SSW’s standard pull request workflow.

When It Runs

  • On PR opened or marked “ready for review”, if it's targeting the main branch
  • Every 2 hours
  • Manually, using the "Run workflow" button in GitHub

What It Does

On PR Creation (pull_request)

  • When a new PR is opened or marked ready:

    • Checks if it's not cross-repository

    • Applies the label:
      Age: 🥚 - New (i.e. "about 2 hours old")

This gives the PR an initial "age" label as a starting point.

🕑 On Schedule (cron)

Every 2 hours, the workflow will:

  1. Ensure labels exist for the following age groups:

    • 🥚 New – 2 hours

    • 🐣 Young – 4 hours

    • 🐥 Adolescent – 8 hours

    • 🐤 Mature – 16 hours

    • 🐓 Old – 32 hours

    • 🍗 Ancient – 64 hours

    • 🦖 Extinct – 128+ hours

  2. Loop through all open PRs

    • Calculates how many hours old each PR is

    • Applies the appropriate age label

    • Removes any other age labels

  3. Add “Merge Debt” label & comment if needed

    • If a PR is over 36 hours old

    • And the author is not a bot

    • And it doesn’t already have a "🔥 Merge Debt" label
      → Then it:

      • Adds the 🔥 Merge Debt label

      • Posts a friendly comment reminding the author to take action:

        "This PR has been here a while... Please action (e.g. get a review) and merge or close."

Clone this wiki locally