-
Notifications
You must be signed in to change notification settings - Fork 334
202 lines (183 loc) · 9.51 KB
/
Copy paththeme_auto_label.yml
File metadata and controls
202 lines (183 loc) · 9.51 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Auto Theme Labeler
on:
issues:
types: [labeled]
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
auto-label:
name: Auto Label Theme
if: contains(github.event.issue.labels.*.name, 'Plugin Request')
runs-on: ubuntu-latest
permissions:
issues: write
outputs:
theme: ${{ steps.add_theme_label.outputs.theme }}
env:
REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
steps:
- name: Get Plugin Website URL
id: get_url
env:
ISSUE_BODY: ${{ github.event.issue.body }}
run: |
URL=$(echo "$ISSUE_BODY" | sed -n '/### Website URL/,+2p' | sed '1,2d' | tr -d '[:space:]')
echo "URL=$URL" >> $GITHUB_OUTPUT
echo "Using URL: \`$URL\`" >> $GITHUB_STEP_SUMMARY
- name: Get Base URL
id: get_base_url
env:
URL: ${{ steps.get_url.outputs.URL }}
run: |
BASE_URL=$(echo "$URL" | sed 's/https\?:\/\///' | cut -d'/' -f1)
echo "BASE_URL=$BASE_URL" >> $GITHUB_OUTPUT
echo "Using Base URL: \`$BASE_URL\`" >> $GITHUB_STEP_SUMMARY
- name: Get User Agent
id: get_user_agent
run: |
CHROME_VERSION=$(curl -s https://chromiumdash.appspot.com/fetch_releases?channel=Stable\&platform=Windows\&num=1 | jq -r '.[0].version // "126.0.6478.36"')
echo "USER_AGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$CHROME_VERSION Safari/537.36" >> $GITHUB_OUTPUT
- name: Check Madara Theme
id: check_madara
env:
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
run: |
echo "🔍 Checking for Madara theme..." >> $GITHUB_STEP_SUMMARY
if curl --location --output /dev/null --silent --head --fail --max-time 10 "https://$BASE_URL/wp-content/themes/madara/style.css" -H "User-Agent: $USER_AGENT" 2>/dev/null || \
curl --location --output /dev/null --silent --head --fail --max-time 10 "http://$BASE_URL/wp-content/themes/madara/style.css" -H "User-Agent: $USER_AGENT" 2>/dev/null; then
echo "madara=true" >> $GITHUB_OUTPUT
echo "✅ Madara Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "madara=false" >> $GITHUB_OUTPUT
echo "❌ Madara Theme Not Found" >> $GITHUB_STEP_SUMMARY
fi
- name: Check Lightnovelwp Theme
id: check_lighnovelwp
if: always() && steps.check_madara.outputs.madara != 'true'
env:
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
run: |
echo "🔍 Checking for Lightnovelwp theme..." >> $GITHUB_STEP_SUMMARY
if curl --location --output /dev/null --silent --head --fail --max-time 10 "https://$BASE_URL/wp-content/themes/lightnovel/style.css" -H "User-Agent: $USER_AGENT" 2>/dev/null || \
curl --location --output /dev/null --silent --head --fail --max-time 10 "http://$BASE_URL/wp-content/themes/lightnovel/style.css" -H "User-Agent: $USER_AGENT" 2>/dev/null; then
echo "lighnovelwp=true" >> $GITHUB_OUTPUT
echo "✅ Lightnovelwp Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "lighnovelwp=false" >> $GITHUB_OUTPUT
echo "❌ Lightnovelwp Theme Not Found" >> $GITHUB_STEP_SUMMARY
fi
- name: Check HotNovelPub Theme
id: check_hotnovelpub
if: always() && steps.check_madara.outputs.madara != 'true' && steps.check_lighnovelwp.outputs.lighnovelwp != 'true'
env:
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
run: |
echo "🔍 Checking for HotNovelPub theme..." >> $GITHUB_STEP_SUMMARY
if curl --location --silent --fail --max-time 10 "https://api.$BASE_URL" -H "User-Agent: $USER_AGENT" 2>/dev/null | grep -q "Hello\!" || \
curl --location --silent --fail --max-time 10 "http://api.$BASE_URL" -H "User-Agent: $USER_AGENT" 2>/dev/null | grep -q "Hello\!"; then
echo "hotnovelpub=true" >> $GITHUB_OUTPUT
echo "✅ HotNovelPub Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "hotnovelpub=false" >> $GITHUB_OUTPUT
echo "❌ HotNovelPub Theme Not Found" >> $GITHUB_STEP_SUMMARY
fi
- name: Check Fictioneer Theme
id: check_fictioneer
if: always() && steps.check_madara.outputs.madara != 'true' && steps.check_lighnovelwp.outputs.lighnovelwp != 'true' && steps.check_hotnovelpub.outputs.hotnovelpub != 'true'
env:
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
run: |
echo "🔍 Checking for Fictioneer theme..." >> $GITHUB_STEP_SUMMARY
if curl --location --output /dev/null --silent --head --fail --max-time 10 "https://$BASE_URL/wp-content/themes/fictioneer/css/application.css" -H "User-Agent: $USER_AGENT" 2>/dev/null || \
curl --location --output /dev/null --silent --head --fail --max-time 10 "http://$BASE_URL/wp-content/themes/fictioneer/css/application.css" -H "User-Agent: $USER_AGENT" 2>/dev/null; then
echo "fictioneer=true" >> $GITHUB_OUTPUT
echo "✅ Fictioneer Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "fictioneer=false" >> $GITHUB_OUTPUT
echo "❌ Fictioneer Theme Not Found" >> $GITHUB_STEP_SUMMARY
fi
- name: Add Theme Label To Issue
id: add_theme_label
if: always()
env:
MADARA: ${{ steps.check_madara.outputs.madara }}
LIGHNOVELWP: ${{ steps.check_lighnovelwp.outputs.lighnovelwp }}
HOTNOVELPUB: ${{ steps.check_hotnovelpub.outputs.hotnovelpub }}
FICTIONEER: ${{ steps.check_fictioneer.outputs.fictioneer }}
GH_TOKEN: ${{ github.token }}
run: |
echo "## Theme Detection Result" >> $GITHUB_STEP_SUMMARY
if [[ "$MADARA" == "true" ]]; then
echo "🏷️ Adding label: Theme: Madara" >> $GITHUB_STEP_SUMMARY
gh issue edit $ISSUE_NUMBER --add-label "Theme: Madara" -R $REPO
echo "theme=madara" >> "$GITHUB_OUTPUT"
elif [[ "$LIGHNOVELWP" == "true" ]]; then
echo "🏷️ Adding label: Theme: Lighnovelwp" >> $GITHUB_STEP_SUMMARY
gh issue edit $ISSUE_NUMBER --add-label "Theme: Lighnovelwp" -R $REPO
echo "theme=lightnovelwp" >> "$GITHUB_OUTPUT"
elif [[ "$HOTNOVELPUB" == "true" ]]; then
echo "🏷️ Adding label: Theme: Hotnovelpub" >> $GITHUB_STEP_SUMMARY
gh issue edit $ISSUE_NUMBER --add-label "Theme: Hotnovelpub" -R $REPO
echo "theme=hotnovelpub" >> "$GITHUB_OUTPUT"
elif [[ "$FICTIONEER" == "true" ]]; then
echo "🏷️ Adding label: Theme: Fictioneer" >> $GITHUB_STEP_SUMMARY
gh issue edit $ISSUE_NUMBER --add-label "Theme: Fictioneer" -R $REPO
echo "theme=fictioneer" >> "$GITHUB_OUTPUT"
else
echo "❌ No Theme Detected" >> $GITHUB_STEP_SUMMARY
fi
create-source-pr:
name: Create MultiSrc Draft PR
needs: auto-label
if: needs.auto-label.outputs.theme != ''
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: master
- name: Add Source Configuration
id: add_source
env:
ISSUE_BODY: ${{ github.event.issue.body }}
THEME: ${{ needs.auto-label.outputs.theme }}
run: node .github/scripts/add-multisrc-source.cjs
- name: Setup Node.js
if: steps.add_source.outputs.changed == 'true'
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
cache: npm
- name: Install Dependencies
if: steps.add_source.outputs.changed == 'true'
run: npm ci --omit=dev --ignore-scripts
- name: Validate Source Configuration
if: steps.add_source.outputs.changed == 'true'
run: |
node -e "JSON.parse(require('fs').readFileSync('plugins/multisrc/${{ needs.auto-label.outputs.theme }}/sources.json', 'utf8'))"
npm run build:multisrc
- name: Create Draft Pull Request
if: steps.add_source.outputs.changed == 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
commit-message: 'feat: Add ${{ steps.add_source.outputs.source_name }} MultiSrc Source'
branch: 'automation/multisrc-issue-${{ github.event.issue.number }}'
title: 'feat: Add ${{ steps.add_source.outputs.source_name }} MultiSrc Source'
body: |
Adds `${{ steps.add_source.outputs.source_name }}` to the `${{ needs.auto-label.outputs.theme }}` multi-source configuration.
Closes #${{ github.event.issue.number }}
This draft was generated from the theme detected for the plugin request. Before marking it ready, verify theme-specific options such as chapter ordering, browse paths, filters, custom parsing, and language.
labels: 'bot'
base: 'master'
delete-branch: true
draft: true