mirror of
https://github.com/multipleof4/gitea-github-cron.git
synced 2026-01-13 16:07:55 +00:00
Fix: Set Gitea Orgs to Public, update if exists
This commit is contained in:
@@ -14,7 +14,7 @@ const req = async (url, h, m = 'GET', b = null) => {
|
|||||||
}
|
}
|
||||||
return res.ok ? (m === 'GET' ? res.json() : res) : null;
|
return res.ok ? (m === 'GET' ? res.json() : res) : null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (m !== 'GET') throw e; // Re-throw for non-GET to handle in loop
|
if (m !== 'GET') throw e;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -48,8 +48,12 @@ const getPages = async (url) => {
|
|||||||
const gOrg = await req(`${G_API}/orgs/${org.login}`, headers.GT);
|
const gOrg = await req(`${G_API}/orgs/${org.login}`, headers.GT);
|
||||||
if (!gOrg) {
|
if (!gOrg) {
|
||||||
console.log(`Creating Org: ${org.login}`);
|
console.log(`Creating Org: ${org.login}`);
|
||||||
await req(`${G_API}/orgs`, headers.GT, 'POST', { username: org.login, visibility: 'private' });
|
await req(`${G_API}/orgs`, headers.GT, 'POST', { username: org.login, visibility: 'public' });
|
||||||
|
} else if (gOrg.visibility !== 'public') {
|
||||||
|
console.log(`Updating Org Visibility: ${org.login}`);
|
||||||
|
await req(`${G_API}/orgs/${org.login}`, headers.GT, 'PATCH', { visibility: 'public' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const orgRepos = await getPages(`https://api.github.com/orgs/${org.login}/repos?type=all`);
|
const orgRepos = await getPages(`https://api.github.com/orgs/${org.login}/repos?type=all`);
|
||||||
allRepos.push(...orgRepos);
|
allRepos.push(...orgRepos);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user