Skip to content

Commit d8f6ae3

Browse files
author
Mark Daugherty
committed
feat: update github repos
1 parent 7585bf2 commit d8f6ae3

2 files changed

Lines changed: 28 additions & 16 deletions

File tree

.github/scripts/fetch-github-repos.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ function pick(repo) {
3232
}, {});
3333
}
3434

35-
async function fetchRepos(username, type) {
36-
const base = type === 'org'
37-
? `https://api.github.com/orgs/${encodeURIComponent(username)}/repos`
38-
: `https://api.github.com/users/${encodeURIComponent(username)}/repos`;
35+
async function fetchRepo(owner, repo) {
36+
const url = `https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`;
3937

4038
const headers = {
4139
Accept: 'application/vnd.github+json',
@@ -44,33 +42,36 @@ async function fetchRepos(username, type) {
4442
const token = process.env.GITHUB_TOKEN;
4543
if (token) headers.Authorization = `Bearer ${token}`;
4644

47-
const response = await fetch(
48-
`${base}?per_page=100&sort=updated&direction=desc`,
49-
{ headers },
50-
);
45+
const response = await fetch(url, { headers });
5146

5247
if (!response.ok) {
53-
throw new Error(`GitHub API returned ${response.status} for ${username}`);
48+
throw new Error(`GitHub API returned ${response.status} for ${owner}/${repo}`);
5449
}
5550

56-
return (await response.json()).map(pick);
51+
return pick(await response.json());
5752
}
5853

5954
async function main() {
6055
const config = JSON.parse(readFileSync(CONFIG_PATH, 'utf8'));
6156
mkdirSync(OUTPUT_DIR, { recursive: true });
6257

6358
const results = await Promise.allSettled(
64-
config.map(async ({ username, type }) => {
65-
const repos = await fetchRepos(username, type || 'user');
66-
const outPath = join(OUTPUT_DIR, `${username}.json`);
67-
writeFileSync(outPath, JSON.stringify(repos, null, 2));
68-
console.log(`✓ ${username}: ${repos.length} repos → ${outPath}`);
59+
config.map(async (entry) => {
60+
const [owner, repo] = entry.split('/');
61+
const data = await fetchRepo(owner, repo);
62+
console.log(`✓ ${entry}`);
63+
return data;
6964
}),
7065
);
7166

7267
const failures = results.filter((r) => r.status === 'rejected');
7368
failures.forEach((r) => console.error('✗', r.reason.message));
69+
70+
const repos = results.filter((r) => r.status === 'fulfilled').map((r) => r.value);
71+
const outPath = join(OUTPUT_DIR, 'repos.json');
72+
writeFileSync(outPath, JSON.stringify(repos, null, 2));
73+
console.log(`\n${repos.length} repos → ${outPath}`);
74+
7475
if (failures.length > 0) process.exit(1);
7576
}
7677

.github/scripts/repos-config.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
[
2-
{ "username": "markdaugherty", "type": "user" }
2+
"orbinson/aem-groovy-console",
3+
"icfnext/prosper",
4+
"CID15/veneer",
5+
"icfnext/akamai-purge-replication-event-handler",
6+
"icfnext/osgi-bundle-status-maven-plugin",
7+
"icfnext/aem-package-maven-plugin",
8+
"icfnext/aem-groovy-extension",
9+
"icfnext/aem-library",
10+
"AvionosLLC/cacheable-renditions",
11+
"AvionosLLC/purge-surgeon",
12+
"AvionosLLC/groovy-console-csv-extension",
13+
"markdaugherty/sling-org-apache-sling-testing-clients"
314
]

0 commit comments

Comments
 (0)