Skip to content

Commit 4436731

Browse files
authored
Update empty-repos.yml
1 parent 24933c5 commit 4436731

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

.github/workflows/empty-repos.yml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,90 @@
1-
name: "Empty repo check"
1+
name: "Monthly Repo Health Report"
22

33
on:
44
schedule:
5-
- cron: '0 0 1 * *' # 00:00 UTC on day 1 of every month
6-
workflow_dispatch: # also allow manual runs
5+
- cron: '0 0 1 * *'
6+
workflow_dispatch:
7+
inputs:
8+
visibility:
9+
description: 'Which repos to scan: all, public, or private'
10+
required: true
11+
default: 'all'
12+
type: choice
13+
options:
14+
- all
15+
- public
16+
- private
717

818
permissions:
919
contents: read
1020
issues: write
1121

1222
env:
13-
SCAN_ORG: YOUR-ORG-HERE
23+
SCAN_ORG: github # ← your org here
1424

1525
jobs:
1626
report:
1727
runs-on: ubuntu-latest
1828

1929
steps:
20-
- name: Generate empty/README-only report 🕵️‍♂️
30+
- name: Generate empty/README-only report 🕵️
2131
uses: actions/github-script@v6
2232
with:
2333
github-token: ${{ secrets.GITHUB_TOKEN }}
2434
script: |
25-
const org = process.env.SCAN_ORG;
26-
// 1) Fetch all repos in the org
27-
const all = await github.paginate(
35+
const org = process.env.SCAN_ORG;
36+
const visibility = '${{ github.event.inputs.visibility }}';
37+
const repos = await github.paginate(
2838
github.rest.repos.listForOrg,
2939
{ org, per_page: 100 }
3040
);
3141
32-
const empty = [];
33-
const readmeOnly= [];
42+
const empty = [], readmeOnly = [];
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;
3448
35-
for (const repo of all) {
3649
let contents;
3750
try {
38-
// list root directory
3951
const res = await github.rest.repos.getContent({
40-
owner: org, repo: repo.name, path: ""
52+
owner: org, repo: r.name, path: ""
4153
});
4254
contents = Array.isArray(res.data) ? res.data : [res.data];
4355
} catch (e) {
44-
// 409 means “empty repo”
4556
if (e.status === 409) contents = [];
4657
else throw e;
4758
}
4859
4960
if (contents.length === 0) {
50-
empty.push(repo.full_name);
61+
empty.push(r.full_name);
5162
} else {
52-
// filter-out any README* files
5363
const nonReadmes = contents.filter(f =>
5464
!/^README(\.[a-z]+)?$/i.test(f.name)
5565
);
5666
if (nonReadmes.length === 0) {
57-
readmeOnly.push(repo.full_name);
67+
readmeOnly.push(r.full_name);
5868
}
5969
}
6070
}
6171
62-
// 2) Only create an issue if we found some
6372
if (empty.length + readmeOnly.length === 0) {
64-
console.log("✔ No empty/README-only repos found. Skipping issue.");
73+
console.log("✔ No matching repos found. Skipping issue.");
6574
return;
6675
}
6776
68-
// 3) Build markdown table
6977
const today = new Date().toISOString().slice(0,10);
7078
let body = `# Repo Health Report for \`${org}\` (${today})\n\n`;
79+
body += `**Visibility:** ${visibility}\n\n`;
7180
body += "| Repository | Status |\n| --- | --- |\n";
72-
for (const r of empty) body += `| ${r} | empty |\n`;
73-
for (const r of readmeOnly) body += `| ${r} | README-only |\n`;
74-
body += "\n_This issue is generated automatically on the 1st of each month._";
81+
for (const u of empty) body += `| ${u} | empty |\n`;
82+
for (const u of readmeOnly) body += `| ${u} | README-only |\n`;
83+
body += "\n_Automatically generated on the 1st of each month._";
7584
76-
// 4) Open an issue in THIS repo
7785
await github.rest.issues.create({
7886
owner: context.repo.owner,
7987
repo: context.repo.repo,
80-
title: `Empty Repo Check: ${org} (${today})`,
88+
title: `Monthly Repo Health: ${org} (${today})`,
8189
body
8290
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy