Skip to content

Add a Back/ return button #9

Add a Back/ return button

Add a Back/ return button #9

name: Extension Issue Handling
on:
issues:
types: [opened]
jobs:
check-extension-issue:
runs-on: ubuntu-latest
steps:
- name: Fetch Extension Data
id: fetch-extensions
uses: actions/github-script@v6
with:
script: |
const repos = [
"https://kodjodevf.github.io/mangayomi-extensions/index.json",
"https://kodjodevf.github.io/mangayomi-extensions/anime_index.json"
];
const extensionNames = new Set();
for (const repo of repos) {
try {
const response = await fetch(repo);
const data = await response.json();
data.forEach(extension => {
if (extension.name) {
extensionNames.add(extension.name.toLowerCase());
}
});
console.log(`✅ Successfully fetched extensions from ${repo}`);
} catch (error) {
console.error(`❌ Error fetching ${repo}:`, error);
}
}
console.log('📝 Found extensions:', Array.from(extensionNames).join(', '));
core.setOutput('extension_names', Array.from(extensionNames).join(','));
- name: Check Issue Content
id: check-issue
uses: actions/github-script@v6
with:
script: |
function normalizeExtensionName(name) {
const original = name;
const normalized = name
.toLowerCase()
.replace(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>/?]/g, ' ')
.replace(/\s+/g, ' ')
.trim();
console.log(`🔍 Normalizing: "${original}" -> "${normalized}"`);
return normalized;
}
function findExtensionMatch(content, extensionNames) {
console.log('\n📖 Checking content:', content);
for (const extension of extensionNames) {
const normalizedExtension = normalizeExtensionName(extension);
console.log(`\n⚡ Checking against extension: ${extension}`);
// Check if extension name appears as a complete word or phrase
if (content.toLowerCase().includes(` ${normalizedExtension} `) ||
content.toLowerCase().startsWith(`${normalizedExtension} `) ||
content.toLowerCase().endsWith(` ${normalizedExtension}`)) {
console.log(`✅ Complete word/phrase match found! "${extension}"`);
return extension;
}
console.log(`❌ No match found for "${extension}"`);
}
console.log('❌ No extension match found in content');
return null;
}
function isExtensionRelatedIssue(title, body) {
const commonProblemWords = [
'doesnt', 'doesn\'t', 'not', 'error', 'broken', 'issue', 'problem',
'crash', 'fail', 'failed', 'failing', 'down', 'work', 'working',
'loading', 'load', 'dead', 'fix', 'broken', 'bug', 'bugs', 'problems',
'issues', 'errors', 'cant', 'can\'t', 'cannot', 'wrong', 'help',
'stuck', 'freezing', 'freeze', 'frozen', 'stopped', 'stopping',
'blank', 'empty', 'missing', 'unavailable', 'slow'
];
const content = (title + ' ' + body).toLowerCase();
const foundWords = commonProblemWords.filter(word => content.includes(word));
if (foundWords.length > 0) {
console.log('✅ Found problem-indicating words:', foundWords.join(', '));
return true;
}
console.log('❌ No problem-indicating words found');
return false;
}
const extensionNames = process.env.EXTENSION_NAMES.split(',');
const issueTitle = context.payload.issue.title;
const issueBody = context.payload.issue.body || '';
console.log('\n🎯 Checking Issue:');
console.log('Title:', issueTitle);
console.log('Body:', issueBody);
let isExtensionIssue = false;
let detectedExtension = null;
console.log('\n🔍 Step 1: Checking for extension matches...');
detectedExtension = findExtensionMatch(issueTitle, extensionNames) ||
findExtensionMatch(issueBody, extensionNames);
console.log('\n🔍 Step 2: Checking if issue is extension-related...');
if (detectedExtension) {
isExtensionIssue = isExtensionRelatedIssue(issueTitle, issueBody);
console.log(`Extension found: ${detectedExtension}`);
console.log(`Is problem-related: ${isExtensionIssue}`);
} else {
console.log('❌ No extension found, skipping problem check');
}
console.log('\n📊 Final Results:');
console.log('Is Extension Issue:', isExtensionIssue);
console.log('Detected Extension:', detectedExtension || 'None');
core.setOutput('is_extension_issue', isExtensionIssue.toString());
core.setOutput('detected_extension', detectedExtension || 'Unknown Extension');
env:
EXTENSION_NAMES: ${{ steps.fetch-extensions.outputs.extension_names }}
- name: Comment and Close Extension Issue
if: steps.check-issue.outputs.is_extension_issue == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueNumber = context.issue.number;
const reportedExtension = "${{ steps.check-issue.outputs.detected_extension || 'Unknown Extension' }}";
console.log('🔒 Closing issue:', issueNumber);
console.log('Extension reported:', reportedExtension);
const currentLabels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber
});
for (const label of currentLabels.data) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
name: label.name
});
}
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: ['wontfix']
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: `# Not Our Business!
AnymeX doesn't maintain extensions.
If the extension doesn't work, we cannot help you.
Contact the owner of the respective repository for extension-related problems.`
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
state: 'closed'
});
console.log('✅ Issue processed and closed successfully');