Added an utility that validates GitHub token.
All checks were successful
Test Action / test (push) Successful in 3s

This commit is contained in:
2026-01-11 14:27:32 +01:00
parent fc727877e6
commit 2bb60fc0ed
4 changed files with 45 additions and 2 deletions

29
src/check-token.ts Normal file
View File

@@ -0,0 +1,29 @@
import { parseArgs } from 'util';
import { fetchLatestRelease } from './core/downloader';
async function run() {
const { positionals } = parseArgs({
allowPositionals: true
});
const token = positionals[0] || process.env.GITHUB_TOKEN;
if (!token) {
console.error('Error: No GitHub token provided as an argument or found in GITHUB_TOKEN environment variable.');
process.exit(1);
}
try {
console.log('Verifying GitHub token...');
// Attempt to list latest release of actions/checkout as a test
await fetchLatestRelease('actions/checkout', token);
console.log('\x1b[32mSuccess: The provided GitHub token is valid and has sufficient permissions to access public repositories.\x1b[0m');
} catch (error: any) {
console.error('\x1b[31mError: GitHub token verification failed.\x1b[0m');
console.error(`Reason: ${error.message}`);
process.exit(1);
}
}
run();