203 lines
9.5 KiB
YAML
203 lines
9.5 KiB
YAML
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
|