Add custom SVG favicons, Gitea issue links and templates, and API triage script
Build and Publish Docker Image / test-and-publish (push) Successful in 2m29s
Build and Publish Docker Image / test-and-publish (push) Successful in 2m29s
This commit is contained in:
1 parent
c476e5c816
commit
6ce92b290c
17 files changed
+263
-1
No files matched your search
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Queries Gitea REST API for open issues & pull requests on FaroeGames/oaktracker.
|
||||
* Usage:
|
||||
* node scripts/check-gitea.mjs
|
||||
* node scripts/check-gitea.mjs --issue 12
|
||||
*
|
||||
* For private repos, set GITEA_TOKEN in your environment before running.
|
||||
*/
|
||||
|
||||
const GITEA_BASE = (process.env.GITEA_URL || 'https://git.trevorstocks.ca').replace(/\/+$/, '');
|
||||
const REPO = process.env.GITEA_REPO || 'FaroeGames/oaktracker';
|
||||
const TOKEN = process.env.GITEA_TOKEN || '';
|
||||
|
||||
async function apiGet(endpoint) {
|
||||
const headers = { Accept: 'application/json' };
|
||||
if (TOKEN) headers.Authorization = `token ${TOKEN}`;
|
||||
const url = `${GITEA_BASE}/api/v1/repos/${REPO}${endpoint}`;
|
||||
const res = await fetch(url, { headers });
|
||||
if (!res.ok) {
|
||||
throw new Error(`Gitea API ${res.status} ${res.statusText} at ${url}`);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const issueFlagIdx = args.indexOf('--issue');
|
||||
|
||||
try {
|
||||
if (issueFlagIdx !== -1 && args[issueFlagIdx + 1]) {
|
||||
const num = Number(args[issueFlagIdx + 1]);
|
||||
const issue = await apiGet(`/issues/${num}`);
|
||||
const comments = await apiGet(`/issues/${num}/comments`);
|
||||
console.log(`#${issue.number} [${issue.state.toUpperCase()}] ${issue.title}`);
|
||||
console.log(`URL: ${issue.html_url}`);
|
||||
console.log(`Author: ${issue.user?.login} | Updated: ${issue.updated_at}`);
|
||||
console.log('\n--- Body ---\n' + (issue.body || '(empty)'));
|
||||
if (comments.length) {
|
||||
console.log(`\n--- Comments (${comments.length}) ---`);
|
||||
for (const c of comments) {
|
||||
console.log(`\n@${c.user?.login} (${c.created_at}):\n${c.body}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const [issues, pulls] = await Promise.all([
|
||||
apiGet('/issues?state=open&type=issues&limit=50'),
|
||||
apiGet('/pulls?state=open&limit=50'),
|
||||
]);
|
||||
|
||||
console.log(`Repository: ${GITEA_BASE}/${REPO}`);
|
||||
console.log(`Open Issues: ${issues.length} | Open PRs: ${pulls.length}\n`);
|
||||
|
||||
if (issues.length) {
|
||||
console.log('=== Open Issues ===');
|
||||
for (const i of issues) {
|
||||
const labels = (i.labels || []).map((l) => l.name).join(', ');
|
||||
console.log(`#${i.number}${labels ? ` [${labels}]` : ''} ${i.title} (@${i.user?.login}) -> ${i.html_url}`);
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
if (pulls.length) {
|
||||
console.log('=== Open Pull Requests ===');
|
||||
for (const p of pulls) {
|
||||
console.log(`PR #${p.number} ${p.title} (@${p.user?.login}) -> ${p.html_url}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err.message);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
Reference in new issue
Block a user