Skip to content

Commit

Permalink
Create extension-issue-handling.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmechinmoy authored Dec 24, 2024
1 parent 750451c commit 8075719
Showing 1 changed file with 154 additions and 0 deletions.
154 changes: 154 additions & 0 deletions .github/workflows/extension-issue-handling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Extension Issue Handling
on:
issues:
types: [opened]

jobs:
handle-extension-issues:
permissions:
contents: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Fetch Extensions from Repositories
id: fetch-extensions
run: |
REPOS=(
"https://kodjodevf.github.io/mangayomi-extensions/index.json"
"https://kodjodevf.github.io/mangayomi-extensions/anime_index.json"
)
EXTENSIONS_FILE=extensions.txt
> $EXTENSIONS_FILE
for repo in "${REPOS[@]}"; do
echo "Fetching from $repo"
curl -sL "$repo" | jq -r '.[].name' | \
sed -E 's/^(Aniyomi:|Tachiyomi:|Mangayomi:)//' | \
tr '[:upper:]' '[:lower:]' | \
sed -E 's/[^a-z0-9]//g' >> $EXTENSIONS_FILE
done
sort -u $EXTENSIONS_FILE -o $EXTENSIONS_FILE
EXTENSIONS_LIST=$(paste -sd'|' $EXTENSIONS_FILE)
echo "extensions_list=$EXTENSIONS_LIST" >> $GITHUB_OUTPUT
echo "Number of Extensions: $(wc -l < $EXTENSIONS_FILE)"
cat $EXTENSIONS_FILE
- name: Check Issue Content
if: github.event.action == 'opened'
id: check-issue
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
EXTENSIONS: ${{ steps.fetch-extensions.outputs.extensions_list }}
run: |
CLEAN_TITLE=$(echo "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]//g')
CLEAN_BODY=$(echo "$ISSUE_BODY" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]//g')
echo "Cleaned Title: $CLEAN_TITLE"
echo "Cleaned Body: $CLEAN_BODY"
EXTENSIONS_FILE=extensions.txt
IS_EXTENSION_ISSUE=false
MATCHED_EXTENSION=""
EXTENSION_REGEX_PATTERNS=(
".*(extension|extensions|repo|repositories|source|sources|stream|server).*not working.*"
".*(extension|extensions|repo|repositories|source|sources|stream|server).*doesn't work.*"
".*(extension|extensions|repo|repositories|source|sources|stream|server).*does not work.*"
".*(extension|extensions|repo|repositories|source|sources|stream|server).*cant work.*"
".*(extension|extensions|repo|repositories|source|sources|stream|server).*can't work.*"
".*(no|can't find|cannot find|missing).*extension(s)?.*"
".*(no|can't find|cannot find|missing).*repo(s|sitories)?.*"
".*(no|can't find|cannot find|missing).*source(s)?.*"
".*(no|can't find|cannot find|missing).*stream(s)?.*"
".*(no|can't find|cannot find|missing).*server.*"
".*(server|stream).*not available.*"
".*(server|stream).*unavailable.*"
".*(server|stream).*down.*"
".*{.*}.*(extension|repo|repositories|source|sources).*not working.*"
".*{.*}.*(extension|repo|repositories|source|sources).*issue.*"
".*{.*}.*(extension|repo|repositories|source|sources).*problem.*"
".*(extension|extensions|repo|repositories|source|sources|stream|server).*not available.*"
".*(extension|extensions|repo|repositories|source|sources|stream|server).*missing.*"
".*nothing came up.*source.*look elsewhere.*"
".*no results.*source.*look somewhere else.*"
".*no content.*source.*"
)
for pattern in "${EXTENSION_REGEX_PATTERNS[@]}"; do
if [[ "$CLEAN_TITLE" =~ $pattern ]] || [[ "$CLEAN_BODY" =~ $pattern ]]; then
IS_EXTENSION_ISSUE=true
break
fi
done
if [ "$IS_EXTENSION_ISSUE" = false ] && [ -n "$CLEAN_BODY" ]; then
while IFS= read -r ext; do
if [[ "$CLEAN_BODY" == *"$ext"* ]]; then
IS_EXTENSION_ISSUE=true
MATCHED_EXTENSION="$ext"
break
fi
done < "$EXTENSIONS_FILE"
fi
echo "Is Extension Issue: $IS_EXTENSION_ISSUE"
echo "Matched Extension: $MATCHED_EXTENSION"
if [ "$IS_EXTENSION_ISSUE" = true ]; then
echo "is_extension_issue=true" >> $GITHUB_OUTPUT
echo "detected_extension=$MATCHED_EXTENSION" >> $GITHUB_OUTPUT
else
echo "is_extension_issue=false" >> $GITHUB_OUTPUT
fi
- 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' }}";
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'
});

0 comments on commit 8075719

Please sign in to comment.