-
-
Notifications
You must be signed in to change notification settings - Fork 25
154 lines (135 loc) · 6.11 KB
/
extension-issue-handling.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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'
});