1
---
2
name: 'OSPO Stale Repository Report'
3
description: 'Identifies inactive repositories in your organization and generates an archival recommendation report.'
4
labels: ['ospo', 'maintenance', 'stale-repos']
5
on:
6
schedule:
7
- cron: "3 2 1 * *"
8
workflow_dispatch:
9
inputs:
10
organization:
11
description: "GitHub organization to scan"
12
required: true
13
type: string
14
default: "my-org"
15
inactive_days:
16
description: "Number of days of inactivity before a repo is considered stale"
17
required: false
18
type: number
19
default: 365
20
exempt_repos:
21
description: "Comma-separated list of repos to exempt from the report"
22
required: false
23
type: string
24
default: ""
25
exempt_topics:
26
description: "Comma-separated list of topics — repos with any of these topics are exempt"
27
required: false
28
type: string
29
default: ""
30
activity_method:
31
description: "Method to determine last activity"
32
required: false
33
type: choice
34
options:
35
- pushed
36
- default_branch_updated
37
default: pushed
38
39
permissions:
40
contents: read
41
issues: read
42
43
engine: copilot
44
tools:
45
github:
46
toolsets:
47
- repos
48
- issues
49
bash: true
50
51
safe-outputs:
52
create-issue:
53
max: 1
54
title-prefix: "[Stale Repos] "
55
labels:
56
- stale-repos
57
58
timeout-minutes: 30
59
---
60
61
You are an assistant that audits GitHub repositories for staleness.
62
63
## Inputs
64
65
| Input | Default |
66
|---|---|
67
| `organization` | `my-org` |
68
| `inactive_days` | `365` |
69
| `exempt_repos` | _(none)_ |
70
| `exempt_topics` | _(none)_ |
71
| `activity_method` | `pushed` |
72
73
Use the workflow dispatch inputs if provided; otherwise fall back to the defaults above.
74
75
## Instructions
76
77
### 1. Enumerate repositories
78
79
List **all** repositories in the `organization`. Exclude any repo that is:
80
81
- **Archived** — skip it entirely.
82
- **Listed in `exempt_repos`** — compare repo names (case-insensitive) against the comma-separated list.
83
- **Tagged with an exempt topic** — if the repo has any topic that appears in the comma-separated `exempt_topics` list, skip it.
84
85
### 2. Determine last activity date
86
87
For each remaining repo, determine the **last activity date** based on `activity_method`:
88
89
- **`pushed`** — use the repository's `pushed_at` timestamp (this is the default and most efficient method).
90
- **`default_branch_updated`** — fetch the most recent commit on the repo's default branch and use that commit's `committer.date`.
91
92
### 3. Identify stale repos
93
94
Calculate the number of days between the last activity date and **today**. If the number of days exceeds `inactive_days`, mark the repo as **stale**.
95
96
### 4. Generate report
97
98
Build a **Markdown report** with a summary and a table:
99
100
> **Stale Repository Report — \<date\>**
101
> Found **N** repositories with no activity in the last **inactive_days** days.
102
103
| Repository | Days Inactive | Last Push Date | Visibility |
104
|---|---|---|---|
105
| [owner/repo](https://github.com/owner/repo) | 420 | 2024-01-15 | public |
106
107
Sort the table by **Days Inactive** descending (most stale first).
108
109
If there are **no stale repos**, still create the issue but note that all repositories are active.
110
111
### 5. Create or update issue
112
113
Search for an existing **open** issue in the `organization/.github` repo (or the repo this workflow runs in) with the label `stale-repos` and a title starting with `[Stale Repos]`.
114
115
- If an **existing open issue** is found, **update its body** with the new report.
116
- If **no open issue** exists, **create a new issue** with:
117
- Title: `[Stale Repos] Inactive Repository Report — <date>`
118
- Label: `stale-repos`
119
- Body: the full Markdown report from step 4.
120