Skip to content

Update check_files.yml #7

Update check_files.yml

Update check_files.yml #7

Workflow file for this run

// ... (previous code remains same until script section)
script: |

Check failure on line 2 in .github/workflows/check_files.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/check_files.yml

Invalid workflow file

You have an error in your yaml syntax on line 2
// ... (previous functions remain same)
for (const dir of dirs) {
const fileCount = countFiles(dir);
console.log(`Checking ${dir}: ${fileCount} files found`);
if (fileCount >= 5) {
const dayNumber = dir.match(/\d+/)[0];
try {
// First, let's list all labels in the repository to debug
console.log(`Getting all labels in the repository...`);
const allLabels = await github.rest.issues.listLabelsForRepo({
owner: context.repo.owner,
repo: context.repo.repo
});
console.log('Available labels:', allLabels.data.map(l => l.name));
// Now search for issues
console.log(`Searching for issues with Day-${dayNumber}`);
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
// Filter issues that have matching labels
const matchingIssues = issues.data.filter(issue => {
const issueLabels = issue.labels.map(label => label.name);
console.log(`Issue #${issue.number} has labels:`, issueLabels);
return issueLabels.some(label =>
label === `Day-${dayNumber}` ||
label === `Day ${dayNumber}` ||
label.toLowerCase() === `day-${dayNumber}`.toLowerCase() ||
label.toLowerCase() === `day ${dayNumber}`.toLowerCase()
);
});
console.log(`Found ${matchingIssues.length} matching issues`);
for (const issue of matchingIssues) {
console.log(`Closing issue #${issue.number}`);
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed',
state_reason: 'completed'
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `This issue has been automatically closed as ${fileCount} files have been uploaded to the ${dir} folder.`
});
}
} catch (error) {
console.error(`Error processing ${dir}:`, error);
console.error('Full error:', JSON.stringify(error, null, 2));
}
}
}