fix: github workflow
This commit is contained in:
38
.github/workflows/build-database.yml
vendored
38
.github/workflows/build-database.yml
vendored
@@ -59,6 +59,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Build awesome database
|
- name: Build awesome database
|
||||||
id: build
|
id: build
|
||||||
|
env:
|
||||||
|
CI: true
|
||||||
run: |
|
run: |
|
||||||
# Capture start time
|
# Capture start time
|
||||||
START_TIME=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
START_TIME=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||||
@@ -68,43 +70,27 @@ jobs:
|
|||||||
INDEX_MODE="${{ github.event.inputs.index_mode || 'full' }}"
|
INDEX_MODE="${{ github.event.inputs.index_mode || 'full' }}"
|
||||||
echo "Index mode: $INDEX_MODE"
|
echo "Index mode: $INDEX_MODE"
|
||||||
|
|
||||||
# Build the index with automated selection
|
# Build the index in non-interactive mode
|
||||||
if [ "$INDEX_MODE" = "sample" ]; then
|
|
||||||
# For sample mode, we'll need to modify the script to accept input
|
|
||||||
echo "Building sample index (10 lists)..."
|
|
||||||
timeout 150m node -e "
|
timeout 150m node -e "
|
||||||
const indexer = require('./lib/indexer');
|
const indexer = require('./lib/indexer');
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
// Simulate user choosing 'sample' option
|
await indexer.buildIndex(false, '${INDEX_MODE}');
|
||||||
process.stdin.push('sample\n');
|
console.log('Index built successfully');
|
||||||
await indexer.buildIndex(false);
|
|
||||||
console.log('Sample index built successfully');
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to build index:', error.message);
|
console.error('Failed to build index:', error.message);
|
||||||
|
console.error(error.stack);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
" || echo "Index building completed with timeout"
|
" || {
|
||||||
else
|
EXIT_CODE=$?
|
||||||
echo "Building full index..."
|
if [ $EXIT_CODE -eq 124 ]; then
|
||||||
timeout 150m node -e "
|
echo "Index building timed out after 150 minutes"
|
||||||
const indexer = require('./lib/indexer');
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
// Simulate user choosing 'full' option
|
|
||||||
process.stdin.push('full\n');
|
|
||||||
await indexer.buildIndex(false);
|
|
||||||
console.log('Full index built successfully');
|
|
||||||
process.exit(0);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to build index:', error.message);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
" || echo "Index building completed with timeout"
|
|
||||||
fi
|
fi
|
||||||
|
exit $EXIT_CODE
|
||||||
|
}
|
||||||
|
|
||||||
# Capture end time
|
# Capture end time
|
||||||
END_TIME=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
END_TIME=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
|||||||
@@ -89,11 +89,23 @@ function isAwesomeList(url, name, description) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the complete index
|
// Build the complete index
|
||||||
async function buildIndex(force = false) {
|
async function buildIndex(force = false, mode = null) {
|
||||||
console.clear();
|
console.clear();
|
||||||
console.log(purpleGold('\n🚀 AWESOME INDEX BUILDER 🚀\n'));
|
console.log(purpleGold('\n🚀 AWESOME INDEX BUILDER 🚀\n'));
|
||||||
|
|
||||||
|
// Check if running in CI/non-interactive mode
|
||||||
|
const isNonInteractive = process.env.CI === 'true' || mode !== null;
|
||||||
|
|
||||||
if (force) {
|
if (force) {
|
||||||
|
if (isNonInteractive) {
|
||||||
|
// Clear index data without confirmation in CI
|
||||||
|
console.log(chalk.gray('\nClearing existing index...'));
|
||||||
|
const dbInstance = require('./database').getDb();
|
||||||
|
dbInstance.exec('DELETE FROM readmes');
|
||||||
|
dbInstance.exec('DELETE FROM repositories');
|
||||||
|
dbInstance.exec('DELETE FROM awesome_lists');
|
||||||
|
console.log(chalk.green('✓ Index cleared\n'));
|
||||||
|
} else {
|
||||||
const { confirm } = await inquirer.prompt([
|
const { confirm } = await inquirer.prompt([
|
||||||
{
|
{
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
@@ -113,6 +125,7 @@ async function buildIndex(force = false) {
|
|||||||
dbInstance.exec('DELETE FROM awesome_lists');
|
dbInstance.exec('DELETE FROM awesome_lists');
|
||||||
console.log(chalk.green('✓ Index cleared\n'));
|
console.log(chalk.green('✓ Index cleared\n'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch main awesome list
|
// Fetch main awesome list
|
||||||
const spinner = ora(chalk.hex('#DA22FF')('Fetching the awesome list of awesome lists...')).start();
|
const spinner = ora(chalk.hex('#DA22FF')('Fetching the awesome list of awesome lists...')).start();
|
||||||
@@ -132,8 +145,11 @@ async function buildIndex(force = false) {
|
|||||||
const awesomeLists = parseMarkdownLinks(mainReadme);
|
const awesomeLists = parseMarkdownLinks(mainReadme);
|
||||||
console.log(chalk.green(`✓ Found ${awesomeLists.length} awesome lists!\n`));
|
console.log(chalk.green(`✓ Found ${awesomeLists.length} awesome lists!\n`));
|
||||||
|
|
||||||
// Ask user what to index
|
let indexChoice = mode;
|
||||||
const { indexChoice } = await inquirer.prompt([
|
|
||||||
|
// Ask user what to index (only if interactive)
|
||||||
|
if (!isNonInteractive) {
|
||||||
|
const result = await inquirer.prompt([
|
||||||
{
|
{
|
||||||
type: 'list',
|
type: 'list',
|
||||||
name: 'indexChoice',
|
name: 'indexChoice',
|
||||||
@@ -147,14 +163,25 @@ async function buildIndex(force = false) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
indexChoice = result.indexChoice;
|
||||||
|
}
|
||||||
|
|
||||||
if (indexChoice === 'cancel') return;
|
if (indexChoice === 'cancel') return;
|
||||||
|
|
||||||
|
// Default to 'full' if no mode specified
|
||||||
|
if (!indexChoice) indexChoice = 'full';
|
||||||
|
|
||||||
|
console.log(chalk.cyan(`Index mode: ${indexChoice}\n`));
|
||||||
|
|
||||||
let listsToIndex = awesomeLists;
|
let listsToIndex = awesomeLists;
|
||||||
|
|
||||||
if (indexChoice === 'sample') {
|
if (indexChoice === 'sample') {
|
||||||
listsToIndex = awesomeLists.sort(() => 0.5 - Math.random()).slice(0, 10);
|
listsToIndex = awesomeLists.sort(() => 0.5 - Math.random()).slice(0, 10);
|
||||||
} else if (indexChoice === 'select') {
|
} else if (indexChoice === 'select') {
|
||||||
|
if (isNonInteractive) {
|
||||||
|
console.log(chalk.yellow('Select mode not available in non-interactive mode, using full'));
|
||||||
|
indexChoice = 'full';
|
||||||
|
} else {
|
||||||
const categories = [...new Set(awesomeLists.map(l => l.category).filter(Boolean))];
|
const categories = [...new Set(awesomeLists.map(l => l.category).filter(Boolean))];
|
||||||
const { selectedCategories } = await inquirer.prompt([
|
const { selectedCategories } = await inquirer.prompt([
|
||||||
{
|
{
|
||||||
@@ -173,6 +200,7 @@ async function buildIndex(force = false) {
|
|||||||
|
|
||||||
listsToIndex = awesomeLists.filter(l => selectedCategories.includes(l.category));
|
listsToIndex = awesomeLists.filter(l => selectedCategories.includes(l.category));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log(pinkPurple(`\n✨ Starting index of ${listsToIndex.length} awesome lists ✨\n`));
|
console.log(pinkPurple(`\n✨ Starting index of ${listsToIndex.length} awesome lists ✨\n`));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user