1
- name : " Monthly Repo Health Report"
1
+ name : " Monthly Empty- Repo Report"
2
2
3
3
on :
4
4
schedule :
5
- - cron : ' 0 0 1 * *'
5
+ - cron : ' 0 0 1 * *' # Runs on the 1st of every month
6
6
workflow_dispatch :
7
7
inputs :
8
8
visibility :
@@ -20,7 +20,7 @@ permissions:
20
20
issues : write
21
21
22
22
env :
23
- SCAN_ORG : github # ← your org here
23
+ SCAN_ORG : github # ← update with your GitHub org if different
24
24
25
25
jobs :
26
26
report :
@@ -32,31 +32,33 @@ jobs:
32
32
with :
33
33
github-token : ${{ secrets.GITHUB_TOKEN }}
34
34
script : |
35
- const org = process.env.SCAN_ORG;
36
- const visibility = '${{ github.event.inputs.visibility }}';
35
+ const org = process.env.SCAN_ORG;
36
+ const visibility = '${{ github.event.inputs.visibility || 'all' }}';
37
37
const repos = await github.paginate(
38
38
github.rest.repos.listForOrg,
39
39
{ org, per_page: 100 }
40
40
);
41
41
42
42
const empty = [], readmeOnly = [];
43
43
44
- for (const r of repos) {
45
- // skip by visibility
46
- if (visibility === 'public' && r.private) continue;
47
- if (visibility === 'private' && !r.private) continue;
44
+ for (const r of repos) {
45
+ // skip by visibility
46
+ if (visibility === 'public' && r.private) continue;
47
+ if (visibility === 'private' && !r.private) continue;
48
48
49
- if (r.archived) continue; // 👈 skip archived repositories
49
+ // skip archived repos
50
+ if (r.archived) continue;
50
51
51
- let contents;
52
- ...
52
+ let contents;
53
53
try {
54
54
const res = await github.rest.repos.getContent({
55
- owner : org, repo: r.name, path: ""
55
+ owner: org,
56
+ repo: r.name,
57
+ path: ""
56
58
});
57
59
contents = Array.isArray(res.data) ? res.data : [res.data];
58
60
} catch (e) {
59
- if (e.status === 409) contents = [];
61
+ if (e.status === 409) contents = []; // empty repo
60
62
else throw e;
61
63
}
62
64
@@ -81,13 +83,13 @@ for (const r of repos) {
81
83
let body = `# Empty Repo Report for \`${org}\` (${today})\n\n`;
82
84
body += `**Visibility:** ${visibility}\n\n`;
83
85
body += "| Repository | Status |\n| --- | --- |\n";
84
- for (const u of empty) body += `| ${u} | empty |\n`;
86
+ for (const u of empty) body += `| ${u} | empty |\n`;
85
87
for (const u of readmeOnly) body += `| ${u} | README-only |\n`;
86
88
body += "\n_Automatically generated on the 1st of each month._";
87
89
88
90
await github.rest.issues.create({
89
91
owner: context.repo.owner,
90
- repo : context.repo.repo,
92
+ repo: context.repo.repo,
91
93
title: `Monthly Repo Health: ${org} (${today})`,
92
94
body
93
95
});
0 commit comments